-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
async_hooks: only disable promise hook if wanted
The promise hook has been disabled asynchronously in order to solve issues when an async hook is disabled during a microtask. This means that after scheduling the disable-promise-hook call, attempts to enable it synchronously will later be unintentionally overridden. In order to solve this, make sure that the promise hooks are still no longer desired at the time at which we would disable them. Fixes: #27585 PR-URL: #27590 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
- Loading branch information
Showing
3 changed files
with
36 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const async_hooks = require('async_hooks'); | ||
|
||
// Regression test for https://github.com/nodejs/node/issues/27585. | ||
|
||
async_hooks.createHook({ init: () => {} }).enable().disable().enable(); | ||
async_hooks.createHook({ init: () => {} }).enable(); | ||
|
||
async function main() { | ||
const initialAsyncId = async_hooks.executionAsyncId(); | ||
await 0; | ||
assert.notStrictEqual(async_hooks.executionAsyncId(), initialAsyncId); | ||
} | ||
|
||
main().then(common.mustCall()); |