Skip to content

Commit 3a5a2ae

Browse files
StefanStojanovicdanielleadams
authored andcommitted
test: fix test-watch-mode-inspect
Refs: #44898 PR-URL: #45586 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Erick Wendel <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 1ff8f68 commit 3a5a2ae

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

test/sequential/test-watch-mode-inspect.mjs

+22-14
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,34 @@ if (common.isIBMi)
1212

1313
common.skipIfInspectorDisabled();
1414

15+
let gettingDebuggedPid = false;
16+
17+
async function getDebuggedPid(instance, waitForLog = true) {
18+
gettingDebuggedPid = true;
19+
const session = await instance.connectInspectorSession();
20+
await session.send({ method: 'Runtime.enable' });
21+
if (waitForLog) {
22+
await session.waitForConsoleOutput('log', 'safe to debug now');
23+
}
24+
const { value: innerPid } = (await session.send({
25+
'method': 'Runtime.evaluate', 'params': { 'expression': 'process.pid' }
26+
})).result;
27+
session.disconnect();
28+
gettingDebuggedPid = false;
29+
return innerPid;
30+
}
31+
1532
function restart(file) {
1633
writeFileSync(file, readFileSync(file));
17-
const interval = setInterval(() => writeFileSync(file, readFileSync(file)), 500);
34+
const interval = setInterval(() => {
35+
if (!gettingDebuggedPid) {
36+
writeFileSync(file, readFileSync(file));
37+
}
38+
}, common.platformTimeout(500));
1839
return () => clearInterval(interval);
1940
}
2041

2142
describe('watch mode - inspect', () => {
22-
async function getDebuggedPid(instance, waitForLog = true) {
23-
const session = await instance.connectInspectorSession();
24-
await session.send({ method: 'Runtime.enable' });
25-
if (waitForLog) {
26-
await session.waitForConsoleOutput('log', 'safe to debug now');
27-
}
28-
const { value: innerPid } = (await session.send({
29-
'method': 'Runtime.evaluate', 'params': { 'expression': 'process.pid' }
30-
})).result;
31-
session.disconnect();
32-
return innerPid;
33-
}
34-
3543
it('should start debugger on inner process', async () => {
3644
const file = fixtures.path('watch-mode/inspect.js');
3745
const instance = new NodeInstance(['--inspect=0', '--watch'], undefined, file);

0 commit comments

Comments
 (0)