Re: [whatwg/streams] Add support for ReadableStream "transfer" type (PR #1271)

> * We could introduce a second optional parameter to controller.enqueue, something like `enqueue(any message, sequence<object> transfer = [])` and update accordingly the `StructuredTransferOrClone` algorithm. This would make it closer to postMessage.

I like that a lot! 🙂 I understand that it's a bit out-of-scope for this PR, but I'd love to see that in a follow-up PR.

When we do add this, I would suggest we use an options object though, to align with [`postMessage(message, { transfer })`](https://html.spec.whatwg.org/multipage/web-messaging.html#dom-messageport-postmessage-dev). That makes it easier to add extra options for `enqueue()` and `write()` in the future.

`ResetQueue` would then transfer away ownership of all transfer lists still in the queue, without needing a separate `[[isTransferring]]` flag. In essence, `type: "transfer"` would merely force `enqueue(chunk)` to always be handled as `enqueue(chunk, { transfer: [chunk] })`.

> I think the current version of the PR is ready for reference implementation prototyping.
> Should I update the reference implementation in this PR as well?

Yes, please. Each spec change on the Streams standard should be accompanied with new WPT tests, and the reference implementation should pass those new tests.

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

Message ID: <whatwg/streams/pull/1271/c1504867016@github.com>

Received on Wednesday, 12 April 2023 08:24:28 UTC