Open
Description
The original transferable streams issue has been closed now that support has been landed, however the discussion of the double transfer problem that started at #276 (comment) and consumed the rest of the thread is not concluded.
Summarising the issue, the following code works fine:
const worker = new Worker(`data:text/javascript,onmessage = evt => postMessage(evt.data, [evt.data]);`);
const rs = new ReadableStream();
worker.postMessage(rs, [rs]);
let transferred_rs;
worker.onmessage = evt => { transferred_rs = evt.data; };
However, if you subsequently run worker.terminate()
then transferred_rs
will start returning errors. For other transferable types, no connection remains with any previous realms that the object was passed through, but in the case of streams, data is still being proxied via the worker.
See the linked thread for why this is hard to fix.