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)

Thank you for the elaboration. But I have a follow-up question: how is being able to peek at the backing buffer (one that the caller brings themselves, i.e. after the "BYOB" fashion), much less one a caller explicitly asks to be loaded, "unsafe", before the promise settles? Even if I peek while, say, _half a byte_ has made it into the buffer, because the implementation for some inexplicable reason does bitwise or'ing, let's say -- how does that make for lack of _safety_? Can you define safety more concretely, for this particular issue? I mean we that word gets thrown around a lot, but it's such a "catch-all". What if the specification rather mandates that before the promise settles, the data in the buffer are not defined? Or that attempting to use the buffer passed to `read` before the promise it returns settles, must throw an error? If safety means integrity of sorts, well, it certainly should not "crash" the interpreter nor expose some sensitive data that weren't in the buffer earlier or aren't going to end up in the buffer later. It's not like an implementation is allowed to temporarily "loan" the buffer for unrelated data, is it? The data that is written to the buffer ends up there eventually anyway. Even if it progressively fills up _bitwise_ (4 bits being flipped into place at a time, let's say), I don't see lack of _safety_? Did you have any concrete examples in mind that demonstrate how this safety would be compromised?

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

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

Received on Sunday, 27 July 2025 19:05:53 UTC