mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
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: https://github.com/nodejs/node/pull/66255 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
5d9228d5c3
commit
4cd4701f69
1 file changed
+6
-3
@@ -33,7 +33,6 @@ function waitUntilDebugged() {
|
||||
|
||||
// This function is called by the inspector client (session)
|
||||
function setupTimeoutWithBreak() {
|
||||
clearInterval(waiting);
|
||||
process._rawDebug('Debugger ready, setting up timeout with a break');
|
||||
setTimeout(() => { debugger; }, 50);
|
||||
}
|
||||
@@ -46,16 +45,20 @@ async function waitForInitialSetup(session) {
|
||||
|
||||
async function setupTimeoutForStackTrace(session) {
|
||||
console.error('[test]', 'Setting up timeout for async stack trace');
|
||||
// Async hook setup is deferred when requested from a V8 interrupt. Let the
|
||||
// event loop finish that setup before creating the timeout whose stack we test.
|
||||
await session.send([
|
||||
{ 'method': 'Runtime.evaluate',
|
||||
'params': { expression: 'setupTimeoutWithBreak()' } },
|
||||
'params': {
|
||||
expression: 'clearInterval(waiting); setImmediate(setupTimeoutWithBreak)',
|
||||
} },
|
||||
{ 'method': 'Debugger.resume' },
|
||||
]);
|
||||
}
|
||||
|
||||
async function checkAsyncStackTrace(session) {
|
||||
console.error('[test]', 'Verify basic properties of asyncStackTrace');
|
||||
const paused = await session.waitForBreakOnLine(23, '[eval]');
|
||||
const paused = await session.waitForBreakOnLine(22, '[eval]');
|
||||
assert(paused.params.asyncStackTrace,
|
||||
`${Object.keys(paused.params)} contains "asyncStackTrace" property`);
|
||||
assert(paused.params.asyncStackTrace.description, 'Timeout');
|
||||
|
||||
Reference in new issue
Block a user