src: add callback scope for native immediates · nodejs/node@7e2cd72 · GitHub
Skip to content

Commit 7e2cd72

Browse files
committed
src: add callback scope for native immediates
This ensures that microtasks scheduled by native immediates are run after the tasks are done. In particular, this affects the inspector integration since 6f9f546. Fixes: #33002 Refs: #32523 Backport-PR-URL: #35241 PR-URL: #34366 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 1474405 commit 7e2cd72

3 files changed

Lines changed: 38 additions & 7 deletions

File tree

src/env.cc

Lines changed: 3 additions & 0 deletions

test/async-hooks/test-late-hook-enable.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ const fnsToTest = [setTimeout, (cb) => {
1717
});
1818
});
1919
}, (cb) => {
20-
process.nextTick(() => {
21-
cb();
20+
setImmediate(() => {
21+
process.nextTick(() => {
22+
cb();
2223

23-
// We need to keep the event loop open for this to actually work
24-
// since destroy hooks are triggered in unrefed Immediates
25-
setImmediate(() => {
26-
hook.disable();
27-
assert.strictEqual(fnsToTest.length, 0);
24+
// We need to keep the event loop open for this to actually work
25+
// since destroy hooks are triggered in unrefed Immediates
26+
setImmediate(() => {
27+
hook.disable();
28+
assert.strictEqual(fnsToTest.length, 0);
29+
});
2830
});
2931
});
3032
}];

test/cctest/test_environment.cc

Lines changed: 26 additions & 0 deletions

0 commit comments

Comments
 (0)