Skip to content

Identify async_hooks use cases beyond AsyncLocalStorage #437

Open
@Qard

Description

@Qard

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions