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

@MattiasBuelens commented on this pull request.



> @@ -6368,7 +6390,11 @@ for="value-with-size">value</dfn> and <dfn for="value-with-size">size</dfn>.
  1. Assert: |container| has \[[queue]] and \[[queueTotalSize]] internal slots.
  1. If ! [$IsNonNegativeNumber$](|size|) is false, throw a {{RangeError}} exception.
  1. If |size| is +∞, throw a {{RangeError}} exception.
- 1. [=list/Append=] a new [=value-with-size=] with [=value-with-size/value=] |value| and
+ 1. Let |enqueuedValue| be |value|.
+ 1. If |container|.\[[isTransferring]] is true, perform the following steps:

`EnqueueValueWithSize` is also used by `WritableStreamDefaultControllerWrite` and `WritableStreamDefaultControllerClose`, but `WritableStreamDefaultController` does not have an `[[isTransferring]]` slot.

I think we should move the transferring logic out of `EnqueueValueWithSize`, and instead put it at the call site in `ReadableStreamDefaultControllerEnqueue`.

> @@ -6388,6 +6414,10 @@ for="value-with-size">value</dfn> and <dfn for="value-with-size">size</dfn>.
  performs the following steps:
 
  1. Assert: |container| has \[[queue]] and \[[queueTotalSize]] internal slots.
+ 1. If |container|.\[[isTransferring]] is true, perform the following steps until |container|.\[[queue]]

Same problem as above.

Maybe add a `ReadableStreamDefaultControllerResetQueue` abstract op which "wraps" `ResetQueue`?

> @@ -6596,6 +6626,18 @@ The following abstract operations are a grab-bag of utilities.
  1. Return ? [$StructuredDeserialize$](|serialized|, [=the current Realm=]).
 </div>
 
+<div algorithm>
+ <dfn abstract-op lt="StructuredTransferOrSerialize">StructuredTransferOrSerialize(|value|)</dfn>
+    performs the following steps:
+ 1. If |value| is [=transferable objects|transferable=], perform the following steps:
+    // FIXME: We should probably handle other transferable types like ArrayBuffers.
+    1. Let |serialized| be ! [$StructuredSerializeWithTransfer$](|value|, « |value| »).
+    1. Let |deserialized| be ! [$StructuredDeserializeWithTransfer$](|serialized|,
+       [=the current Realm=]).
+    1. return |deserialized|.\[[Deserialized]].
+ 1. return [$StructuredClone$](|value|).

```suggestion
 1. Return [$StructuredClone$](|value|).
```

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

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

Received on Tuesday, 11 April 2023 09:32:59 UTC