Skip to content

fix: always terminate active Node Streams#43071

Merged
ckerr merged 1 commit into31-x-yfrom
trop/31-x-y-bp-fix-always-terminate-active-node-streams-1722101150853
Jul 27, 2024
Merged

fix: always terminate active Node Streams#43071
ckerr merged 1 commit into31-x-yfrom
trop/31-x-y-bp-fix-always-terminate-active-node-streams-1722101150853

Conversation

@trop
Copy link
Contributor

@trop trop bot commented Jul 27, 2024

Backport of #43056

See that PR for details.

Notes: Fixed the resource leak when using Node.js readable streams as the response body for a custom protocol handler.

`.destroy()` is an important method in the lifecycle of a Node.js
Readable stream. It is typically called to reclaim the resources
(e.g., close file descriptor). The only situations where calling
it manually isn't necessary are when the following events are
emitted first:

- `end`: natural end of a stream
- `error`: stream terminated due to a failure

Prior to this commit the ended state was incorrectly tracked together
with a pending internal error. It led to situations where the request
could get aborted during a read and then get marked as ended (having
pending error).

With this change we disentangle pending "error" and "destroyed" cases to
always properly terminate an active Node.js Readable stream.

Co-authored-by: Fedor Indutny <[email protected]>
@trop trop bot requested a review from a team July 27, 2024 17:26
@trop trop bot mentioned this pull request Jul 27, 2024
5 tasks
@trop trop bot added 31-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Jul 27, 2024
@ckerr ckerr merged commit 6322c32 into 31-x-y Jul 27, 2024
@ckerr ckerr deleted the trop/31-x-y-bp-fix-always-terminate-active-node-streams-1722101150853 branch July 27, 2024 19:47
@release-clerk
Copy link

release-clerk bot commented Jul 27, 2024

Release Notes Persisted

Fixed the resource leak when using Node.js readable streams as the response body for a custom protocol handler.

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

Labels

31-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant