Skip to content

Commit 8d20b64

Browse files
mcollinamarco-ippolito
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 <contact@viniciusl.com.br> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent f1b7bda commit 8d20b64

File tree

3 files changed

+0
-30
lines changed

3 files changed

+0
-30
lines changed

lib/internal/webstreams/transfer.js

-3
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ class CrossRealmTransformReadableSource {
146146
error);
147147
port.close();
148148
};
149-
150-
port.unref();
151149
}
152150

153151
start(controller) {
@@ -221,7 +219,6 @@ class CrossRealmTransformWritableSink {
221219
port.close();
222220
};
223221

224-
port.unref();
225222
}
226223

227224
start(controller) {

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
@@ -454,23 +454,12 @@ const theData = 'hello';
454454
tracker.verify();
455455
});
456456
457-
// We create an interval to keep the event loop alive while
458-
// we wait for the stream read to complete. The reason this is needed is because there's
459-
// otherwise nothing to keep the worker thread event loop alive long enough to actually
460-
// complete the read from the stream. Under the covers the ReadableStream uses an
461-
// unref'd MessagePort to communicate with the main thread. Because the MessagePort
462-
// is unref'd, it's existence would not keep the thread alive on its own. There was previously
463-
// a bug where this MessagePort was ref'd which would block the thread and main thread
464-
// from terminating at all unless the stream was consumed/closed.
465-
const i = setInterval(() => {}, 1000);
466-
467457
parentPort.onmessage = tracker.calls(({ data }) => {
468458
assert(isReadableStream(data));
469459
const reader = data.getReader();
470460
reader.read().then(tracker.calls((result) => {
471461
assert(!result.done);
472462
assert(result.value instanceof Uint8Array);
473-
clearInterval(i);
474463
}));
475464
parentPort.close();
476465
});

0 commit comments

Comments
 (0)