Repository navigation
Expand file tree
/
Copy pathjetExitIgnoreKill.test.js
More file actions
80 lines (72 loc) · 2.81 KB
/
Copy pathjetExitIgnoreKill.test.js
File metadata and controls
80 lines (72 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const fs = require('fs');
const path = require('path');
const {
killJetIgnoringExit,
raceCallerErrorAgainstJetExit,
} = require('../../../tests/e2e/jetExitIgnoreKill');
const repoRoot = path.resolve(__dirname, '../../..');
describe('jetExitIgnoreKill (await-exit stall vs exitPromise race)', function () {
it('sets ignoreExit before invoking kill', async function () {
const events = [];
await killJetIgnoringExit({
setIgnoreExit: value => {
events.push(['setIgnoreExit', value]);
},
kill: async () => {
events.push(['kill']);
},
});
expect(events).toEqual([['setIgnoreExit', true], ['kill']]);
});
it('preserves retryable stall error when ignoreExit gates the close handler', async function () {
const stallErr = new Error(
'[rnfb-e2e] Jet awaiting-jet-exit stalled 1200000ms after launch-ready — aborting cell',
);
stallErr.retryableAtJetLevel = true;
let caught;
try {
await raceCallerErrorAgainstJetExit({
callerError: stallErr,
ignoreExitDuringKill: true,
});
} catch (err) {
caught = err;
}
expect(caught).toBe(stallErr);
expect(caught.retryableAtJetLevel).toBe(true);
expect(caught.message).toMatch(/awaiting-jet-exit stalled/);
});
it('NEGATIVE: without ignoreExit, bare Jet exit error wins the race', async function () {
const stallErr = new Error(
'[rnfb-e2e] Jet awaiting-jet-exit stalled 1200000ms after launch-ready — aborting cell',
);
stallErr.retryableAtJetLevel = true;
let caught;
try {
await raceCallerErrorAgainstJetExit({
callerError: stallErr,
ignoreExitDuringKill: false,
});
} catch (err) {
caught = err;
}
expect(caught).not.toBe(stallErr);
expect(caught.message).toBe('Jet tests failed!');
expect(caught.retryableAtJetLevel).toBeUndefined();
});
it('firebase.test.js wires stall kill through killIgnoringExit (not bare killJetForLaunchRetry)', function () {
const src = fs.readFileSync(path.join(repoRoot, 'tests/e2e/firebase.test.js'), 'utf8');
const guardStart = src.indexOf('async function awaitJetExitWithStallGuard');
const guardEnd = src.indexOf('async function killJetForLaunchRetry');
expect(guardStart).toBeGreaterThan(-1);
expect(guardEnd).toBeGreaterThan(guardStart);
const guardBody = src.slice(guardStart, guardEnd);
expect(guardBody).toMatch(/jetSession\.killIgnoringExit\(/);
expect(guardBody).not.toMatch(/killJetForLaunchRetry\(/);
const sessionSrc = fs.readFileSync(path.join(repoRoot, 'tests/e2e/jetSession.js'), 'utf8');
expect(sessionSrc).toMatch(/require\('\.\/jetExitIgnoreKill'\)/);
expect(sessionSrc).toMatch(/async killIgnoringExit\(/);
expect(src).toMatch(/stall-kill-jet/);
expect(src).toMatch(/stall-diagnostics/);
});
});