Identify async_hooks use cases beyond AsyncLocalStorage

Open
#437 34 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
nodejs

Research direction

Start by reviewing the async_hooks and AsyncLocalStorage use cases listed in the issue, then investigate the Clinic uses mentioned in the discussion. Done means documenting additional use cases and identifying which safer APIs could address them without exposing unsafe resource internals.

Written by the indexing model from the issue text.

Description

never stale question

It seems to be the general consensus of this working group that async_hooks should not be directly made stable due to it exposing internals. The AsyncLocalStorage API provides a higher-level solution to many of the use cases of async_hooks, however some use cases still remain. I would like to identify what those use cases are so we can introduce safer APIs solving those problems and eventually move toward deprecating direct use of async_hooks or perhaps just the unsafe aspects of it.

Known use cases:

  • long stack traces
    • Shouldn't make any use of the resource objects, so should be reasonably safe.
  • tracking handle lifecycle
    • The subsystem type, id, and event timings can be used to track high-level lifecycle safely
    • Deeper awareness may involve inspecting the resource object, which could be unsafe
  • measure time spent in blocking code
    • Mainly just need timing between before/after and maybe type for extra context, resource not required

What other use cases are there? I know clinic uses it for some things, perhaps @mcollina has some insight on that?

Dominant language
No language data
Stars
550
Forks
69
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nodejs/diagnostics

All issues in nodejs/diagnostics

Similar issues

More Observability & SRE issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.