Skip to content

async_hooks: If first hook is disabled, async ID tracking is permanently disabled #27585

Closed
@kjin

Description

@kjin
  • Version: v12.0.0
  • Platform: macOS 10.14.3 (likely irrelevant)
  • Subsystem: async_hooks

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:

const ah = require('async_hooks');
// switch the order of these two lines, and things appear to work correctly
ah.createHook({ init: () => {} }).enable().disable().enable();
ah.createHook({ init: () => {} }).enable();

async function main() {
  console.log(ah.executionAsyncId()); // should print 1
  await 0;
  console.log(ah.executionAsyncId()); // should print 7, but prints 1
}

main();

This appears to affect all of v12+ so far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    async_hooksIssues and PRs related to the async hooks subsystem.promisesIssues and PRs related to ECMAScript promises.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions