Skip to content

Async Hooks and Streams #33749

@ronag

Description

@ronag

Continuing a little bit from #33723.

Do we need closer integration between async hooks and streams? In particular since Stream.destroy can be invoked from basically anywhere the 'close' event can be emitted in a for user unexpected async scope (not sure yet about the correct terminology in async hooks context).

What currently seems to be the way to approach this is to monkey patch destroy after creating a stream, e.g.

const stream = new Duplex(...)
stream.destroy = asyncResource.runInAsyncScope.bind(asyncResource, stream.destroy, stream)

Maybe would make sense to be able to provide a asyncId or asyncTriggerId (not sure of the difference yet) as a constructor argument?

Metadata

Metadata

Assignees

No one assigned

    Labels

    async_hooksIssues and PRs related to the async hooks subsystem.streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions