-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Closed
Labels
async_hooksIssues and PRs related to the async hooks subsystem.Issues and PRs related to the async hooks subsystem.promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.
Description
- Version:
- Platform:
- Subsystem:
What steps will reproduce the bug?
const { executionAsyncId, createHook } = require('async_hooks')
const {writeSync} = require('fs')
const {format} = require('util')
// hacky console.error() that doesn't cause more contexts to be created
const log = (...msg) => writeSync(2, format(...msg) + '\n')
const hook = createHook({})
hook.enable()
log('before promises', executionAsyncId())
new Promise(resolve => {
log('eid, first promise', executionAsyncId())
setTimeout(resolve)
}).then(() => new Promise(resolve => {
log('eid, second promise', executionAsyncId())
}))
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
The executionAsyncId
within the Promise
function should be that of the Promise itself, rather than the parent context.
before promises 1
eid, first promise {some number greater than 1 and less than 4}
eid, second promise 4
What do you see instead?
before promises 1
eid, first promise 1
eid, second promise 4
Additional information
Possibly related to #26794, not sure.
Note that the Promise constructor callback does report the proper executionAsyncId when the Promise is created in the context of a Promise chain.
Metadata
Metadata
Assignees
Labels
async_hooksIssues and PRs related to the async hooks subsystem.Issues and PRs related to the async hooks subsystem.promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.