Skip to content

stream: error callbacks after destroy during write/final#63862

Open
cjc0013 wants to merge 1 commit into
nodejs:mainfrom
cjc0013:fix/writable-destroyed-during-write-final
Open

stream: error callbacks after destroy during write/final#63862
cjc0013 wants to merge 1 commit into
nodejs:mainfrom
cjc0013:fix/writable-destroyed-during-write-final

Conversation

@cjc0013

@cjc0013 cjc0013 commented Jun 11, 2026

Copy link
Copy Markdown

Writable streams can be destroyed inside user-provided _write() or _final() implementations before their callback runs. In that gap, the callback could previously continue the write/final completion path as a success even though the stream had already been destroyed.

This change checks for destruction when those callbacks return. If the stream was destroyed without an explicit error, the write or end callback receives ERR_STREAM_DESTROYED, which follows the issue guidance to cancel the remaining completion work and turn a silent destroy into an error.

Validation: node --check lib/internal/streams/writable.js, node --check test/parallel/test-stream-writable-destroy.js, node --check test/parallel/test-stream-writable-final-destroy.js, and git diff --check.

Refs: #39030

@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 the stream subsystem. labels Jun 11, 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 the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants