Skip to content

stream: forward compose tail error after finish - #67674

Open
mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:stream-compose-forward-tail-error
Open

mcollina wants to merge 1 commit into
nodejs:mainfrom
mcollina:stream-compose-forward-tail-error

Conversation

@mcollina

Copy link
Copy Markdown
Member

compose() only listened for 'data' and 'end' on the last stream it was
given. When that stream emitted 'error' after its writable side had
already finished, pipeline() had already removed its own error listener,
so the error reached no listener and was raised as an unhandled 'error'
event, crashing the process.

An example is decompressing truncated gzip input through
compose(source, zlib.createGunzip()): the decompressor's final flush
runs after the writable side has finished, so the Z_BUF_ERROR it raises
on truncation is never delivered to the composed Duplex and instead
crashes the process.

Forward tail errors to the composed Duplex by destroying it whenever the
tail errors before the composition has been destroyed. The for await
consumer and a 'error' listener on the composed Duplex both receive the
error, and the request is no longer killed.

cc @nodejs/streams

compose() only listened for 'data' and 'end' on the last stream it was
given. When that stream emitted 'error' after its writable side had
already finished, pipeline() had already removed its own error listener,
so the error reached no listener and was raised as an unhandled 'error'
event, crashing the process.

Forward tail errors to the composed Duplex by destroying it whenever the
tail errors before the composition has been destroyed.

Signed-off-by: Matteo Collina <matteo.collina@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to Node.js streams. labels Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. stream Issues and PRs related to Node.js streams.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants