Closed
Description
- Version: v10.0.0
- Platform: Linux, Windows 10 WSL
Running the following code
const async_hooks = require("async_hooks");
const fs = require("fs");
async_hooks
.createHook({
init: (asyncId, type, triggerAsyncId, resource) => {
fs.writeSync(1, `${triggerAsyncId} => ${asyncId}\n`);
}
})
.enable();
async function main() {
console.log("hello");
await null;
console.log("hello");
}
main();
on Node 9 gives the output
1 => 6
hello
1 => 7
6 => 8
8 => 9
hello
9 => 10
while on Node 10 it gives
1 => 6
hello
1 => 7
1 => 8
hello
1 => 9
That is, on Node 10, the triggerAsyncId
is always 1, and I am unable to track which contexts follow from which other contexts.
Is one of these unexpected behavior? If the change is a known (undocumented?) new behavior, is there any way with Node 10 to achieve what I was doing under previous versions?