-
-
Notifications
You must be signed in to change notification settings - Fork 35.7k
Expand file tree
/
Copy pathtest-debugger-probe-failure-resume.js
More file actions
80 lines (74 loc) Β· 2.54 KB
/
test-debugger-probe-failure-resume.js
File metadata and controls
80 lines (74 loc) Β· 2.54 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
// This tests that a probe expression resuming the target through its own
// inspector.Session is surfaced as a probe-side failure. The terminal event
// can be either probe_failure or probe_timeout depending on a race in V8's
// nested pause-loop drain.
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const fixtures = require('../common/fixtures');
const { spawnSyncAndExit } = require('../common/child_process');
const { assertProbeJson } = require('../common/debugger-probe');
const cwd = fixtures.path('debugger');
const fixture = 'probe-inspector-resume.js';
const probes = [{
expr: 'callInspectorResume()',
target: { suffix: fixture, line: 12 },
}];
const location = { url: fixtures.fileURL('debugger', fixture).href, line: 12, column: 19 };
spawnSyncAndExit(process.execPath, [
'inspect', '--json',
'--probe', `${fixture}:12`, '--expr', probes[0].expr,
fixture,
], { cwd, env: { ...process.env, NODE_DEBUG: 'inspect_probe' } }, {
status: 1,
signal: null,
stdout(output) {
const expected = {
v: 2,
probes,
results: [{
probe: 0,
event: 'hit',
hit: 1,
location,
result: { type: 'number', value: 1, description: '1' },
}]
};
const actual = JSON.parse(output);
const code = actual.results.at(-1)?.error?.code;
if (code === 'probe_failure') {
expected.results.push({
event: 'error',
pending: [],
error: {
code: 'probe_failure',
message:
'Probe session failed after a probe evaluation. If the ' +
'failure repeats, review the most-recently-evaluated probe ' +
'expression.',
probe: 0,
stderr: '',
details: {
lastCdpMethod: 'Debugger.resume',
protocolError: { message: 'Can only perform operation while paused.', code: -32000 },
},
},
});
} else if (code === 'probe_timeout') {
// On slow CI, the outer Debugger.resume can be picked up in the same drain pass as
// the Debugger.evaluateOnCallFrame, while V8 still considers the context paused.
// In this case both resume calls may succeed and the process can continue running from
// the setInterval until the timeout.
expected.results.push({
event: 'timeout',
pending: [],
error: {
code: 'probe_timeout',
message: 'Timed out after 30000ms waiting for target completion'
},
});
}
assertProbeJson(actual, expected);
},
trim: true,
});