Skip to content

Validate a writable chunk's size only when it is enqueued - #7507

Merged
jasnell merged 1 commit into
mainfrom
jasnell/ts-streams-writable-late-size
Sep 25, 2026
Merged

jasnell merged 1 commit into
mainfrom
jasnell/ts-streams-writable-late-size

Conversation

@jasnell

@jasnell jasnell commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

GetChunkSize rejected a NaN, negative or infinite size() result by erroring the stream, even for a write made after close() that the state checks were about to reject. The close then rejected with the RangeError, and an earlier queued write rejected with it too, without reaching the sink.

The range check moves to controllerWrite, where the spec's EnqueueValueWithSize makes it. A write after close() now rejects alone and the close completes; a live write with an invalid size errors the stream as before.

C++ rejects the late write with its conversion TypeError and, with an earlier write queued, rejects the close too (ledger #9). Behind the experimental typescript_implemented_streams flag.

@jasnell
jasnell requested review from guybedford and npaun September 24, 2026 18:41
@jasnell
jasnell requested review from a team as code owners September 24, 2026 18:41
Comment thread src/tests/streams/writable/backpressure.js
@ask-bonk

ask-bonk Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

Updates writable chunk-size validation timing and adds after-close regression coverage.

  1. Medium Posted 1 inline suggestion for missing size() invocation-order coverage.

github run

@guybedford guybedford left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Verified the new test fails on main (uncaught RangeError) and passes here across the TS and C++ writable configs; //src/wpt:streams-ts@ still passes. The check now sits where EnqueueValueWithSize makes it, and controllerWrite has a single caller so nothing bypasses it.

GetChunkSize rejected a NaN, negative or infinite size() result by
erroring the stream, even for a write made after close() that the state
checks were about to reject. The close then rejected with the
RangeError, and an earlier queued write rejected with it too, without
reaching the sink.

The range check moves to controllerWrite, where the spec's
EnqueueValueWithSize makes it. A write after close() now rejects alone
and the close completes; a live write with an invalid size errors the
stream as before.

C++ rejects the late write with its conversion TypeError and, with an
earlier write queued, rejects the close too (ledger #9). Behind the
experimental typescript_implemented_streams flag.
@jasnell
jasnell force-pushed the jasnell/ts-streams-writable-late-size branch from 3f0f536 to 0a3c563 Compare September 25, 2026 04:24
@jasnell
jasnell enabled auto-merge September 25, 2026 04:25
@jasnell
jasnell merged commit b1724c3 into main Sep 25, 2026
36 of 39 checks passed
@jasnell
jasnell deleted the jasnell/ts-streams-writable-late-size branch September 25, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants