You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
async_hooks: If first hook is disabled, async ID tracking is permanently disabled #27585
If I create an async hook and then disable it, then async ID tracking no longer works, even if subsequent async hooks are created and enabled, or if the first async hook is re-enabled.
Repro:
constah=require('async_hooks');// switch the order of these two lines, and things appear to work correctlyah.createHook({init: ()=>{}}).enable().disable().enable();ah.createHook({init: ()=>{}}).enable();asyncfunctionmain(){console.log(ah.executionAsyncId());// should print 1await0;console.log(ah.executionAsyncId());// should print 7, but prints 1}main();
Sorry, this happened because of my 96c3224 – it just happened to work out before, but the issue here is that disabling the promise hook happens asynchronously, i.e. after all the synchronous enable() calls.
@addaleax Thanks for the fast fix! I checkout out your change and it does seem to fix the underlying issue for the module in which I encountered this problem.
Activity
addaleax commentedon May 6, 2019
Sorry, this happened because of my 96c3224 – it just happened to work out before, but the issue here is that disabling the promise hook happens asynchronously, i.e. after all the synchronous
enable()calls.#27585 should address this. :)
async_hooks: only disable promise hook if wanted
kjin commentedon May 6, 2019
@addaleax Thanks for the fast fix! I checkout out your change and it does seem to fix the underlying issue for the module in which I encountered this problem.
async_hooks: only disable promise hook if wanted
async_hooks: only disable promise hook if wanted