- From: Mattias Buelens <notifications@github.com>
- Date: Fri, 15 Aug 2025 04:06:43 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/pull/1353/review/3123610022@github.com>
@MattiasBuelens commented on this pull request.
> + const byteOffset = view.byteOffset;
+ const byteLength = view.byteLength;
The reference implementation was doing [steps 8 and 9](https://streams.spec.whatwg.org/commit-snapshots/4f2a2c1012342885b2c2d7608fa58ef81631b058/#readable-byte-stream-controller-pull-into) *after* calling `TransferArrayBuffer`, which meant that `view.byteLength` was already `0`. We didn't notice this, because we weren't *actually* transferring before. 😛
Fortunately, all "real" implementations already do this correctly.
> exports.TransferArrayBuffer = O => {
assert(!exports.IsDetachedBuffer(O));
- const transferredIshVersion = O.slice();
-
- // This is specifically to fool tests that test "is transferred" by taking a non-zero-length
- // ArrayBuffer and checking if its byteLength starts returning 0.
- Object.defineProperty(O, 'byteLength', {
- get() {
- return 0;
- }
- });
- O[isFakeDetached] = true;
-
- return transferredIshVersion;
+ return ArrayBufferPrototypeTransferToFixedLength.call(O);
I'm using `transferToFixedLength()` since we don't (yet) support [resizable `ArrayBuffer`s](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer#resizing_arraybuffers).
I think we can loosen that restriction, but we should do that in an *actual* spec change. 😉
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1353#pullrequestreview-3123610022
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/streams/pull/1353/review/3123610022@github.com>
Received on Friday, 15 August 2025 11:06:47 UTC