Re: [whatwg/streams] Why does the `read` method of `ReadableStreamBYOBReader` class, need to _transfer_ the buffer it is provided? (Issue #1348)

amn left a comment (whatwg/streams#1348)

@eqrion, can you link the specification which forbids it? I understand why it would, I just want to chart whether it's WASM or another API specification (or both) that has it specified.

Intuitively, I expect the transferring is mandated because even if we ignore a WASM use case, the underlying implementation of `read`, had it not taken ownership of the buffer by transferring it for its own use, would have to contend for the buffer access with the caller of `read`, which I guess was seen as problematic. And it could well be so -- the caller may try to resize the buffer, for example, before the promise it was returned completes, meaning during the period of time the underlying task is busy reading into the buffer. Is this the kind of thing you generally mean? Because I'd like to illustrate a problematic scenario that has nothing to do with WASM. That would make it clearer which specification is best to address the issue with, and which API to amend, for example.

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

Message ID: <whatwg/streams/issues/1348/3135864761@github.com>

Received on Wednesday, 30 July 2025 11:21:17 UTC