Skip to content

Commit

Permalink
Revert "stream: fix cloned webstreams not being unref'd"
Browse files Browse the repository at this point in the history
This reverts commit 4d3923a.

PR-URL: #51491
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Matthew Aitken <[email protected]>
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
mcollina authored and RafaelGSS committed Jan 19, 2024
1 parent af3203f commit 662ac95
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 34 deletions.
2 changes: 0 additions & 2 deletions lib/internal/webstreams/readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,6 @@ class ReadableStream {

[kTransferList]() {
const { port1, port2 } = new MessageChannel();
port1.unref();
port2.unref();
this[kState].transfer.port1 = port1;
this[kState].transfer.port2 = port2;
return [ port2 ];
Expand Down
4 changes: 1 addition & 3 deletions lib/internal/webstreams/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ class CrossRealmTransformReadableSource {
error);
port.close();
};

port.unref();
}

start(controller) {
Expand Down Expand Up @@ -212,7 +210,7 @@ class CrossRealmTransformWritableSink {
error);
port.close();
};
port.unref();

}

start(controller) {
Expand Down
2 changes: 0 additions & 2 deletions lib/internal/webstreams/writablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@ class WritableStream {

[kTransferList]() {
const { port1, port2 } = new MessageChannel();
port1.unref();
port2.unref();
this[kState].transfer.port1 = port1;
this[kState].transfer.port2 = port2;
return [ port2 ];
Expand Down
16 changes: 0 additions & 16 deletions test/parallel/test-webstreams-clone-unref.js

This file was deleted.

11 changes: 0 additions & 11 deletions test/parallel/test-whatwg-webstreams-transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,23 +464,12 @@ const theData = 'hello';
tracker.verify();
});
// We create an interval to keep the event loop alive while
// we wait for the stream read to complete. The reason this is needed is because there's
// otherwise nothing to keep the worker thread event loop alive long enough to actually
// complete the read from the stream. Under the covers the ReadableStream uses an
// unref'd MessagePort to communicate with the main thread. Because the MessagePort
// is unref'd, it's existence would not keep the thread alive on its own. There was previously
// a bug where this MessagePort was ref'd which would block the thread and main thread
// from terminating at all unless the stream was consumed/closed.
const i = setInterval(() => {}, 1000);
parentPort.onmessage = tracker.calls(({ data }) => {
assert(isReadableStream(data));
const reader = data.getReader();
reader.read().then(tracker.calls((result) => {
assert(!result.done);
assert(result.value instanceof Uint8Array);
clearInterval(i);
}));
parentPort.close();
});
Expand Down

0 comments on commit 662ac95

Please sign in to comment.