Skip to content

Commit e0e43bb

Browse files
panvaaduh95
authored andcommitted
test: deflake inspector async hook setup
Async hook activation can be deferred when the inspector command arrives during a V8 interrupt. Schedule timeout creation with setImmediate so the event loop finishes enabling the hooks before recording its async stack. Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: #66255 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent b030b48 commit e0e43bb

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎test/parallel/test-inspector-async-hook-setup-at-signal.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ function waitUntilDebugged() {
3333
3434
// This function is called by the inspector client (session)
3535
function setupTimeoutWithBreak() {
36-
clearInterval(waiting);
3736
process._rawDebug('Debugger ready, setting up timeout with a break');
3837
setTimeout(() => { debugger; }, 50);
3938
}
@@ -46,16 +45,20 @@ async function waitForInitialSetup(session) {
4645

4746
async function setupTimeoutForStackTrace(session) {
4847
console.error('[test]', 'Setting up timeout for async stack trace');
48+
// Async hook setup is deferred when requested from a V8 interrupt. Let the
49+
// event loop finish that setup before creating the timeout whose stack we test.
4950
await session.send([
5051
{ 'method': 'Runtime.evaluate',
51-
'params': { expression: 'setupTimeoutWithBreak()' } },
52+
'params': {
53+
expression: 'clearInterval(waiting); setImmediate(setupTimeoutWithBreak)',
54+
} },
5255
{ 'method': 'Debugger.resume' },
5356
]);
5457
}
5558

5659
async function checkAsyncStackTrace(session) {
5760
console.error('[test]', 'Verify basic properties of asyncStackTrace');
58-
const paused = await session.waitForBreakOnLine(23, '[eval]');
61+
const paused = await session.waitForBreakOnLine(22, '[eval]');
5962
assert(paused.params.asyncStackTrace,
6063
`${Object.keys(paused.params)} contains "asyncStackTrace" property`);
6164
assert(paused.params.asyncStackTrace.description, 'Timeout');

0 commit comments

Comments
 (0)