Skip to content

IncomingMessage and OutgoingMessage's destroy ignores the second argument callback, swallowing the error #28236

Description

@zen0wu
  • Version: 12.4.0
  • Platform: Mac OS
  • Subsystem:

Use case: Treat a streaming HTTP response as an AsyncIterable and iterate through to do some processing.

  1. When an error happens in the async iterable stream processing,
  2. The error is propagated to the underlying stream with a callback to be triggered the rejection of the promise: https://github.com/nodejs/node/blob/49f1bb9b93/lib/internal/streams/async_iterator.js#L118
  3. When the underlying stream is IncomingMessage (in my case, or OutgoingMessage), destroy don't even take the callback, hence ignoring the error: https://github.com/nodejs/node/blob/49f1bb9b93/lib/_http_incoming.js#L102

Activity

  1. added
    httpIssues and PRs related to the http subsystem.
    on Jul 13, 2019
  2. ronag commented on Jun 16, 2020

    @ronag
    Member

    This looks like a bug. We should use finished instead of the extra callback variant of destroy.

  3. ronag commented on Jun 16, 2020

    @ronag
    Member

    I believe this was fixed in: #31316

  4. jasnell commented on Jun 26, 2020

    @jasnell
    Member

    Closing. We can reopen if it turns out that #31316 did not fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues and PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions