src: add callback scope for native immediates by addaleax · Pull Request #34366 · nodejs/node · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/env.cc
16 changes: 9 additions & 7 deletions test/async-hooks/test-late-hook-enable.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ const fnsToTest = [setTimeout, (cb) => {
});
});
}, (cb) => {
process.nextTick(() => {
cb();
setImmediate(() => {
process.nextTick(() => {
cb();

// We need to keep the event loop open for this to actually work
// since destroy hooks are triggered in unrefed Immediates
setImmediate(() => {
hook.disable();
assert.strictEqual(fnsToTest.length, 0);
// We need to keep the event loop open for this to actually work
// since destroy hooks are triggered in unrefed Immediates
setImmediate(() => {
hook.disable();
assert.strictEqual(fnsToTest.length, 0);
});
});
});
}];
Expand Down
26 changes: 26 additions & 0 deletions test/cctest/test_environment.cc