Re: [whatwg/streams] Fix assertion failure in RespondInternal after transferring array buffer in RespondWithNewView (#1174)

Good catch! 👍 The reference implementation doesn't correctly implement `TransferArrayBuffer`, so it's hard to catch these kinds of errors before browsers start implementing. (It'd really help if Chromium implemented `self.structuredClone()`, but [#1233571](https://crbug.com/1233571) is still open. 😛)

Could you update [the reference implementation](https://github.com/whatwg/streams/blob/1147c01d0e0ca89dec053ddf93b11d2f7734270e/reference-implementation/lib/abstract-ops/readable-streams.js#L1637-L1639) to reflect the spec text changes?

> @MattiasBuelens I'm wondering if you have any context on why we changed the standard to use `TransferArrayBuffer()` in `RespondWithNewView()`?

When you respond to a BYOB request, we must immediately take back control of the buffer so we can (later on) give it back to the initiating read-into request. If we didn't transfer the buffer immediately, then you could do something like:
```javascript
const view = controller.byobRequest.view;
view[0] = 12;
controller.byobRequest.respondWithNewView(view.subarray(0, 1));
view[0] = 34; // shouldn't be possible!
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1174#issuecomment-940810225

Received on Tuesday, 12 October 2021 09:00:23 UTC