Skip to content

Commit 662ac95

Browse files
mcollinaRafaelGSS
authored andcommitted
Revert "stream: fix cloned webstreams not being unref'd"
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]>
1 parent af3203f commit 662ac95

File tree

5 files changed

+1
-34
lines changed

5 files changed

+1
-34
lines changed

lib/internal/webstreams/readablestream.js

-2
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,6 @@ class ReadableStream {
596596

597597
[kTransferList]() {
598598
const { port1, port2 } = new MessageChannel();
599-
port1.unref();
600-
port2.unref();
601599
this[kState].transfer.port1 = port1;
602600
this[kState].transfer.port2 = port2;
603601
return [ port2 ];

lib/internal/webstreams/transfer.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ class CrossRealmTransformReadableSource {
143143
error);
144144
port.close();
145145
};
146-
147-
port.unref();
148146
}
149147

150148
start(controller) {
@@ -212,7 +210,7 @@ class CrossRealmTransformWritableSink {
212210
error);
213211
port.close();
214212
};
215-
port.unref();
213+
216214
}
217215

218216
start(controller) {

lib/internal/webstreams/writablestream.js

-2
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ class WritableStream {
266266

267267
[kTransferList]() {
268268
const { port1, port2 } = new MessageChannel();
269-
port1.unref();
270-
port2.unref();
271269
this[kState].transfer.port1 = port1;
272270
this[kState].transfer.port2 = port2;
273271
return [ port2 ];

test/parallel/test-webstreams-clone-unref.js

-16
This file was deleted.

test/parallel/test-whatwg-webstreams-transfer.js

-11
Original file line numberDiff line numberDiff line change
@@ -464,23 +464,12 @@ const theData = 'hello';
464464
tracker.verify();
465465
});
466466
467-
// We create an interval to keep the event loop alive while
468-
// we wait for the stream read to complete. The reason this is needed is because there's
469-
// otherwise nothing to keep the worker thread event loop alive long enough to actually
470-
// complete the read from the stream. Under the covers the ReadableStream uses an
471-
// unref'd MessagePort to communicate with the main thread. Because the MessagePort
472-
// is unref'd, it's existence would not keep the thread alive on its own. There was previously
473-
// a bug where this MessagePort was ref'd which would block the thread and main thread
474-
// from terminating at all unless the stream was consumed/closed.
475-
const i = setInterval(() => {}, 1000);
476-
477467
parentPort.onmessage = tracker.calls(({ data }) => {
478468
assert(isReadableStream(data));
479469
const reader = data.getReader();
480470
reader.read().then(tracker.calls((result) => {
481471
assert(!result.done);
482472
assert(result.value instanceof Uint8Array);
483-
clearInterval(i);
484473
}));
485474
parentPort.close();
486475
});

0 commit comments

Comments
 (0)