Read detached and out-of-bounds DataView chunks as empty - #7516
Merged
Merged
Conversation
Contributor
|
LGTM |
guybedford
approved these changes
Sep 25, 2026
jasnell
force-pushed
the
jasnell/ts-streams-detached-dataview
branch
from
September 25, 2026 23:05
b92e7b1 to
92d7f16
Compare
|
The generated output of |
The DataView byteOffset and byteLength getters throw a TypeError on a
view whose buffer is detached, or that a resizable buffer has shrunk out
from under; the typed-array getters report 0 for the same view. Five
TypeScript paths read caller-supplied views through those getters
unguarded, so such a DataView chunk:
- rejected an IdentityTransformStream / FixedLengthStream write;
- errored a CompressionStream / DecompressionStream (the write, later
writes, close() and the readable all rejected);
- errored a DigestStream (its digest then never settles, as after any
erroring write in either implementation);
- errored a native-backed writable with a highWaterMark (e.g. connect()
with { highWaterMark }), whose byte-counting size callback threw;
- failed body collection (Response/Request of a JS value stream) when
out of bounds; the drain loop already skipped detached views.
The C++ implementation treats all of these as zero-length, as both
implementations already did for typed arrays.
webstreams/view-extent.ts (a leaf module) reads a view's extent through
the captured getters and gives a DataView the typed arrays' answer:
viewByteLength() for the size paths (writable.ts byteSizeOf,
identity.ts byteSize, digest-stream.ts), viewByteExtent() where the
bytes are copied (identity.ts and compression.ts snapshots, readable.ts
collectChunks, replacing its detachment probe).
Pinned under both implementations: identity alreadyDetachedViewAtWrite
and outOfBoundsViewAtWrite now cover DataViews; new compression
degenerateViewsAreNoops, digest degenerateViewsHashAsEmpty, sockets
degenerateViewsWithHighWaterMark; readable
bodyConsumptionNormalizesBufferSourceChunks adds out-of-bounds views.
Each fails in the TypeScript cells without the fix. Behind the
experimental typescript_implemented_streams flag.
jasnell
force-pushed
the
jasnell/ts-streams-detached-dataview
branch
from
September 25, 2026 23:24
92d7f16 to
68d99dd
Compare
jasnell
enabled auto-merge
September 25, 2026 23:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixup the handling of DataViews in the TS impl