- From: Mattias Buelens <notifications@github.com>
- Date: Sat, 22 Nov 2025 11:34:28 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/pull/1360@github.com>
I'm proposing we add support for resizable `ArrayBuffer`s to readable byte streams (as suggested in #1248). More specifically, developers should be able to pass an `ArrayBufferView` backed by a resizable `ArrayBuffer` to `ReadableStreamBYOBReader.read(view)`, and have the returned view still be backed by that same (resizable) buffer.
I expect the actual spec change to be fairly small:
* In the WebIDL, we'll add `[AllowResizable]` to the `view` argument to indicate that views can now be backed by both resizable and non-resizable buffers.
* In the specification, we'll need to make sure that we preserve the "resizability" of the backing buffer whenever we need to transfer it.
Expect a draft PR soon, so we can talk about implementation details. 😉
Note that supporting growable `SharedArrayBuffer`s is a non-goal of *this* proposal, but I still intend to open a separate proposal to support `SharedArrayBuffer`s. Then we can finally support reading directly into a (shared) WebAssembly memory. 😁
Open questions:
* Should the underlying byte source be allowed to resize `ReadableStreamBYOBRequest.view.buffer`?
* I'm leaning towards "no", since we don't allow responding with more bytes than requested by `byobRequest.view.byteLength`.
* This can be checked in `byobRequest.respond()` and `.respondWithNewView()`.
* Should we also support resizable buffers for [`autoAllocateChunkSize`](https://streams.spec.whatwg.org/#dom-underlyingsource-autoallocatechunksize)?
* This would allow byte sinks to use memory more efficiently when they are used with a default reader. But are there practical use cases for this?
You can view, comment on, or merge this pull request online at:
https://github.com/whatwg/streams/pull/1360
-- Commit Summary --
* Explain resizable buffers for BYOB readers
* Add end-user benefits and alternatives
-- File Changes --
A explainers/resizable-buffers-for-byob.md (120)
-- Patch Links --
https://github.com/whatwg/streams/pull/1360.patch
https://github.com/whatwg/streams/pull/1360.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1360
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/streams/pull/1360@github.com>
Received on Saturday, 22 November 2025 19:34:32 UTC