Skip to content

stream: validate options.signal in iter Writer methods#64411

Open
SAY-5 wants to merge 1 commit into
nodejs:mainfrom
SAY-5:stream-iter-writer-validate-signal
Open

stream: validate options.signal in iter Writer methods#64411
SAY-5 wants to merge 1 commit into
nodejs:mainfrom
SAY-5:stream-iter-writer-validate-signal

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 10, 2026

Copy link
Copy Markdown

Fixes: #64384

The push(), broadcast() and fromWritable() writers all accept an
options.signal on write(), writev() and end(), but none of them
validated it. A malformed value (for example a string) was silently
accepted: on the sync fast path a truthy non-signal skipped straight into
the async path and threw later, end() ignored it entirely, and the
classic writer never looked at it at all. The constructors already run
validateAbortSignal, so the per-write methods were the only place where a
bad signal slipped through.

This validates options.signal at the start of each writer method, matching
the constructor behaviour and throwing ERR_INVALID_ARG_TYPE consistently.
A valid signal and an absent signal are unaffected. For the classic writer
the signal is still not used for cancellation (that is handled at the
pipeline level), it is only validated.

Added assertions to test-stream-iter-validation.js covering all three
writers.

Signed-off-by: Sai Asish Y <say.apm35@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 the stream subsystem. labels Jul 10, 2026
@trivikr

trivikr commented Jul 10, 2026

Copy link
Copy Markdown
Member

The issue https://www.github.com/nodejs/node/issues/64384 is already assigned, and there's an open PR which is linked as well as approved https://www.github.com/nodejs/node/pull/64385

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.

stream/iter: Writer methods do not consistently validate options.signal

3 participants