Skip to content

Conversation

@MattiasBuelens
Copy link
Collaborator

I'm proposing we add support for resizable ArrayBuffers 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 SharedArrayBuffers is a non-goal of this proposal, but I still intend to open a separate proposal to support SharedArrayBuffers. 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?
    • 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?

@MattiasBuelens MattiasBuelens added the addition/proposal New features or enhancements label Nov 22, 2025
@MattiasBuelens MattiasBuelens force-pushed the resizable-buffers-for-byob-explainer branch from 4b9dc8c to e39ab51 Compare November 22, 2025 19:56
@MattiasBuelens MattiasBuelens requested a review from ricea November 28, 2025 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition/proposal New features or enhancements

Development

Successfully merging this pull request may close these issues.

1 participant