-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed
Closed
Copy link
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: v8.1.0
- Platform: Linux sirius 4.9.9-gms-1 deps: update openssl to 1.0.1j #1 SMP Sun Feb 12 20:43:38 CET 2017 x86_64 GNU/Linux
- Subsystem: async_hooks
Hi,
maybe related to: (#13367),
the init-hook (now?) reports a triggerId of 0 for type 'PROMISE' sometimes
code to reproduce:
const asyncHooks = require('async_hooks');
let beforeId;
asyncHooks
.createHook({
init: (id, type, triggerId) => {
process._rawDebug(`init: id:${id} type:${type} triggerId:${triggerId}`);
},
before: (id) => {
process._rawDebug(`before: id:${id}`);
beforeId = id;
}
})
.enable();
function tracePromise(prefix) {
process._rawDebug(`promise : ${prefix}: currId:${asyncHooks.currentId()} lastId:${beforeId}`);
}
setImmediate(() => {
doTrace = true;
return new Promise((resolve, reject) => {
tracePromise('P1: EXECUTOR FUNC');
resolve();
})
.then(() => {
tracePromise('P1: THEN');
return new Promise((resolve, reject) => {
tracePromise('P2: EXECUTOR FUNC');
resolve();
})
.then(() => {
tracePromise('P2: THEN');
return new Promise((resolve, reject) => {
tracePromise('P3: EXECUTOR FUNC');
resolve();
})
.then(() => {
tracePromise('P3: THEN');
});
});
});
});
output from above:
gms@sirius:~/work/HOT/node-async-context/test (master)$ node promise.js
init: id:2 type:Immediate triggerId:1
before: id:2
init: id:3 type:PROMISE triggerId:2
promise : P1: EXECUTOR FUNC: currId:2 lastId:2
init: id:4 type:PROMISE triggerId:3
before: id:4
promise : P1: THEN: currId:0 lastId:4
init: id:5 type:PROMISE triggerId:0
promise : P2: EXECUTOR FUNC: currId:0 lastId:4
init: id:6 type:PROMISE triggerId:5
before: id:6
promise : P2: THEN: currId:0 lastId:6
init: id:7 type:PROMISE triggerId:0
promise : P3: EXECUTOR FUNC: currId:0 lastId:6
init: id:8 type:PROMISE triggerId:7
init: id:9 type:PROMISE triggerId:6
before: id:8
promise : P3: THEN: currId:0 lastId:8
init: id:10 type:PROMISE triggerId:8
before: id:10
before: id:9
Guenter
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.