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

A few thoughts:
- The current algorithm tries to transfer/serialize only if it is sure to be able to enqueue. This seems a good property to me.
- If transfer/serialization fails, we silently terminate without either throwing or erroring the stream. I wonder whether this will be surprising to web developers.
- Cloning a `transfer:true` stream with transfer-only objects would succeed but the second branch would be errored. This seems ok to me.
- The current transfer-or-clone algorithm has surprising and potentially undesired effects:
  - `enqueue(videoFrame)` would make sure to transfer videoFrame but `enqueue({ videoFrame })` would clone it.
  - 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. In that case, should we keep `enqueue(videoFrame)` as a shortcut to `enqueue(videoFrame, [videoFrame])`?

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

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

Received on Tuesday, 11 April 2023 12:17:54 UTC