-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Closed
Labels
async_hooksIssues and PRs related to the async hooks subsystem.Issues and PRs related to the async hooks subsystem.async_local_storageAsyncLocalStorageAsyncLocalStorage
Description
Consider the following code:
import { AsyncLocalStorage, createHook } from 'node:async_hooks';
import { notEqual } from 'assert/strict';
const hook = createHook({
init () {},
})
// Commenting out this line will make the bug go away
hook.enable();
const asyncLocalStorage = new AsyncLocalStorage();
async function main () {
// Commenting out this line will make the bug go away
await 1
asyncLocalStorage.enterWith({ foo: 'bar' });
}
await main()
console.log(executionAsyncResource());
// Should not be undefined
notEqual(asyncLocalStorage.getStore(), undefined);Note that:
- disabling the hook solve the problem
- removing the
await 1promise solves the problem
Debugging the executionAsyncResource() in this case:
Promise {
<pending>,
[Symbol(async_id_symbol)]: 12,
[Symbol(trigger_async_id_symbol)]: 9
}
while in without the createHook().enable() call:
{ [Symbol(kResourceStore)]: { foo: 'bar' } }
rozzilla, franky47 and fabiancook
Metadata
Metadata
Assignees
Labels
async_hooksIssues and PRs related to the async hooks subsystem.Issues and PRs related to the async hooks subsystem.async_local_storageAsyncLocalStorageAsyncLocalStorage