Skip to content

async_hooks: runtime deprecate createHook() - #67271

Open
mcollina wants to merge 5 commits into
nodejs:mainfrom
mcollina:async-hooks-deprecate-createhook
Open

mcollina wants to merge 5 commits into
nodejs:mainfrom
mcollina:async-hooks-deprecate-createhook

Conversation

@mcollina

@mcollina mcollina commented Nov 5, 2026

Copy link
Copy Markdown
Member

async_hooks.createHook() now emits a DEP0212 deprecation warning. This is the first step of the deprecation cycle suggested in #61030 (comment): warn in the 27 alpha, then require --enable-async-hooks in 27 current.

The AsyncHook class moves to internal/async_hooks, so the inspector and the node.async_hooks trace event category keep using it without emitting the warning.

Printing the warning schedules a tick that a freshly enabled hook sees without a matching init, so the tests that check exact hook invocations now run with --no-deprecation.

Refs: #61030

Emit DEP0212 when async_hooks.createHook() is called, as the first
step before putting it behind a flag.

The inspector and the node.async_hooks trace event category use an
internal createHook() and do not emit the warning.

Refs: nodejs#61030
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/inspector
  • @nodejs/userland-migrations

@nodejs-github-bot nodejs-github-bot added async_hooks Issues and PRs related to the async hooks subsystem. needs-ci PRs that need a full CI run. labels Nov 5, 2026
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina
mcollina requested a review from joyeecheung November 5, 2026 09:48
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.26804% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.39%. Comparing base (9365fff) to head (2fb146d).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/async_hooks.js 36.78% 55 Missing ⚠️
lib/internal/inspector_async_hook.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67271      +/-   ##
==========================================
- Coverage   92.99%   90.39%   -2.61%     
==========================================
  Files         428      797     +369     
  Lines      195754   279470   +83716     
  Branches    30292    53617   +23325     
==========================================
+ Hits       182049   252618   +70569     
- Misses      13378    17158    +3780     
- Partials      327     9694    +9367     
Files with missing lines Coverage Δ
lib/async_hooks.js 100.00% <100.00%> (ø)
lib/internal/trace_events_async_hooks.js 65.97% <100.00%> (-27.84%) ⬇️
lib/internal/inspector_async_hook.js 19.35% <0.00%> (-80.65%) ⬇️
lib/internal/async_hooks.js 59.38% <36.78%> (-38.87%) ⬇️

... and 501 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread lib/internal/async_hooks.js Resolved
Comment thread lib/internal/async_hooks.js Resolved
mcollina and others added 2 commits November 5, 2026 08:21
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

async_hooks Issues and PRs related to the async hooks subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants