-
- Notifications
You must be signed in to change notification settings - Fork 33.8k
Open
Labels
async_hooksIssues and PRs related to the async hooks subsystem.Issues and PRs related to the async hooks subsystem.docIssues and PRs related to the documentations.Issues and PRs related to the documentations.
Description
Affected URL(s)
https://nodejs.org/api/async_hooks.html
Description of the problem
We need a supported way to detect which async callback is blocking the event loop.
Currently, the only feasible approach is using async_hooks.createHook() and measuring the time spent between the before and after callbacks — but the docs recommend avoiding async_hooks.
Why this matters
- Libraries such as blocked-at rely on
async_hooksto identify which async operation is responsible for event loop delays. - Articles like Trigger.dev — Monitoring Event Loop Lag demonstrate this approach in practice.
- The Node.js docs also include similar examples for measuring async operation durations.
As far as I know, there’s currently no alternative API that provides the same level of visibility.
Limitations of existing tools
perf_hooks.monitorEventLoopDelaycan detect that lag is happening — but not what caused it.- CPU profiling can identify the blocking function, but only if we already know when the problem occurs so we can capture the profile at the right time.
Question
How can we migrate away from the async_hooks API for this use case, as recommended by the docs?
Is there a supported or planned alternative for attributing event loop delay to a specific async callback?
purplepenguin2
Metadata
Metadata
Assignees
Labels
async_hooksIssues and PRs related to the async hooks subsystem.Issues and PRs related to the async hooks subsystem.docIssues and PRs related to the documentations.Issues and PRs related to the documentations.