Re: [whatwg/streams] can streams be transferred via postMessage()? (#276)

I'm not in favour of making double-transfers fail. They're useful in scenarios where you don't tear down the middle context. For example, I use them in the tests 😄

Synchronously transferring the state of a WritableStream is looking increasingly difficult to me. For example, `writeAlgorithm` returns a promise. We can't clone or transfer the promise, and we can't synchronously observe its state. With code like the following:
```js
writer.write(chunk);
writer.releaseLock();
worker.postMessage(writable, [writable]);
```
`postMessage` would need to synchronously observe the state of the stream. But the state of the stream depends on whether or not `chunk` could be serialized, information which is encoded in the promise returned by `writeAlgorithm`.

PipeTo doesn't have a problem with this because it operates asynchronously.

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

Received on Tuesday, 21 July 2020 20:38:49 UTC