Commit c3189d436e1 for nodejs
commit c3189d436e14202a764d59aa35526ef9c44d9f6b
Author: Ethan Arrowood <ethan@arrowood.dev>
Date: Fri Sep 4 10:21:32 2026 -0600
test: replace discard loops with dump()
Replaces the `for await (const _ of source) {}` discard idiom with
dump(), which says what it does and does not need an eslint-disable
for the unused loop variable. The eslint-disable directives and
comments that become redundant are removed with it.
Only files that already declare --experimental-stream-iter are
converted, so no test gains an experimental flag it did not already
opt into. Files still using the old idiom are left as they are;
converting them would change what those tests run under and belongs
in a separate discussion.
Loops that break early are left alone: those cancel the source rather
than reading it to completion, which is not what dump() does.
Assisted-by: Claude Opus 5
Signed-off-by: Ethan Arrowood <ethan@arrowood.dev>
PR-URL: https://github.com/nodejs/node/pull/65598
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
diff --git a/test/parallel/test-quic-cc-algorithm.mjs b/test/parallel/test-quic-cc-algorithm.mjs
index 8b0a00feb5d..0de377c1586 100644
--- a/test/parallel/test-quic-cc-algorithm.mjs
+++ b/test/parallel/test-quic-cc-algorithm.mjs
@@ -6,6 +6,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -39,7 +40,7 @@ for (const cc of ['reno', 'cubic', 'bbr']) {
body: encoder.encode('congestion control test'),
});
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
// Verify the session stats show congestion control was active.
diff --git a/test/parallel/test-quic-datagram-multiple.mjs b/test/parallel/test-quic-datagram-multiple.mjs
index 733322ea047..28f34a28664 100644
--- a/test/parallel/test-quic-datagram-multiple.mjs
+++ b/test/parallel/test-quic-datagram-multiple.mjs
@@ -10,6 +10,7 @@
import { hasQuic, skip, mustCall, mustCallAtLeast } from '../common/index.mjs';
import assert from 'node:assert';
import * as fixtures from '../common/fixtures.mjs';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -72,7 +73,7 @@ for (let i = 0; i < numDatagrams; i++) {
}
// Complete the stream.
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await stream.closed;
// At least some datagrams should have arrived.
diff --git a/test/parallel/test-quic-diagnostics-channel-stream.mjs b/test/parallel/test-quic-diagnostics-channel-stream.mjs
index 96a6074fc37..0a77d9238fe 100644
--- a/test/parallel/test-quic-diagnostics-channel-stream.mjs
+++ b/test/parallel/test-quic-diagnostics-channel-stream.mjs
@@ -9,6 +9,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
import dc from 'node:diagnostics_channel';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -59,7 +60,7 @@ const stream = await clientSession.createBidirectionalStream({
body: encoder.encode('diagnostics test'),
});
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise, clientSession.closed]);
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-flow-control-blob.mjs b/test/parallel/test-quic-flow-control-blob.mjs
index 88856249921..9531f1ee5b6 100644
--- a/test/parallel/test-quic-flow-control-blob.mjs
+++ b/test/parallel/test-quic-flow-control-blob.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -42,7 +43,7 @@ const stream = await clientSession.createBidirectionalStream({
body: blob,
});
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-flow-control-block-resume.mjs b/test/parallel/test-quic-flow-control-block-resume.mjs
index 552932651b1..1de68aa27c6 100644
--- a/test/parallel/test-quic-flow-control-block-resume.mjs
+++ b/test/parallel/test-quic-flow-control-block-resume.mjs
@@ -8,6 +8,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -43,7 +44,7 @@ await clientSession.opened;
const stream = await clientSession.createBidirectionalStream();
stream.setBody(data);
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise, clientSession.closed]);
diff --git a/test/parallel/test-quic-flow-control-params.mjs b/test/parallel/test-quic-flow-control-params.mjs
index 6b0e70ea223..3827a1404a8 100644
--- a/test/parallel/test-quic-flow-control-params.mjs
+++ b/test/parallel/test-quic-flow-control-params.mjs
@@ -12,6 +12,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -63,7 +64,7 @@ const encoder = new TextEncoder();
}
w.endSync();
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-h3-maxstreamdata-external-buffer-failure.mjs b/test/parallel/test-quic-h3-maxstreamdata-external-buffer-failure.mjs
index df74e4db408..e8d849243ac 100644
--- a/test/parallel/test-quic-h3-maxstreamdata-external-buffer-failure.mjs
+++ b/test/parallel/test-quic-h3-maxstreamdata-external-buffer-failure.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip } from '../common/index.mjs';
import { readFile } from 'node:fs/promises';
import { setTimeout as sleep } from 'node:timers/promises';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -33,8 +34,8 @@ const serverMayRead = new Promise((resolve) => { letServerRead = resolve; });
const endpoint = await listen((session) => {
session.onstream = async (stream) => {
await serverMayRead;
- // eslint-disable-next-line no-unused-vars
- for await (const _ of stream) { /* reading extends the window */ }
+ // Reading extends the window
+ await dump(stream);
};
}, {
sni: { '*': { keys: [key], certs: [cert] } },
diff --git a/test/parallel/test-quic-key-update-peer.mjs b/test/parallel/test-quic-key-update-peer.mjs
index 1a0fed1a167..4beefcbae69 100644
--- a/test/parallel/test-quic-key-update-peer.mjs
+++ b/test/parallel/test-quic-key-update-peer.mjs
@@ -6,6 +6,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -41,7 +42,7 @@ await clientSession.opened;
const stream = await clientSession.createBidirectionalStream({
body: encoder.encode('after key update'),
});
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.closed;
diff --git a/test/parallel/test-quic-key-update.mjs b/test/parallel/test-quic-key-update.mjs
index b01288e90f4..9ae52a922d5 100644
--- a/test/parallel/test-quic-key-update.mjs
+++ b/test/parallel/test-quic-key-update.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -42,7 +43,7 @@ clientSession.updateKey();
const stream = await clientSession.createBidirectionalStream();
stream.setBody(data);
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-max-payload-size.mjs b/test/parallel/test-quic-max-payload-size.mjs
index 4aa2314f047..9923f120407 100644
--- a/test/parallel/test-quic-max-payload-size.mjs
+++ b/test/parallel/test-quic-max-payload-size.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -38,7 +39,7 @@ async function transferAndGetPacketCount(maxPayloadSize) {
const stream = await clientSession.createBidirectionalStream();
stream.setBody(new Uint8Array(dataLength));
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
const pktSent = clientSession.stats.pktSent;
diff --git a/test/parallel/test-quic-max-window.mjs b/test/parallel/test-quic-max-window.mjs
index b0ee67afa96..eb4cc8c359b 100644
--- a/test/parallel/test-quic-max-window.mjs
+++ b/test/parallel/test-quic-max-window.mjs
@@ -8,6 +8,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -41,7 +42,7 @@ const dataLength = 8192;
const stream = await clientSession.createBidirectionalStream();
stream.setBody(new Uint8Array(dataLength));
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await Promise.all([stream.closed, serverDone.promise, clientSession.closed]);
await serverEndpoint.close();
}
@@ -69,7 +70,7 @@ const dataLength = 8192;
const stream = await clientSession.createBidirectionalStream();
stream.setBody(new Uint8Array(dataLength));
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await Promise.all([stream.closed, serverDone.promise, clientSession.closed]);
await serverEndpoint.close();
}
diff --git a/test/parallel/test-quic-maxstreamdata-external-buffer-failure.mjs b/test/parallel/test-quic-maxstreamdata-external-buffer-failure.mjs
index 79d11e05794..5126c7bbf4c 100644
--- a/test/parallel/test-quic-maxstreamdata-external-buffer-failure.mjs
+++ b/test/parallel/test-quic-maxstreamdata-external-buffer-failure.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip } from '../common/index.mjs';
import { readFile } from 'node:fs/promises';
import { setTimeout as sleep } from 'node:timers/promises';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -33,8 +34,8 @@ const serverMayRead = new Promise((resolve) => { letServerRead = resolve; });
const endpoint = await listen((session) => {
session.onstream = async (stream) => {
await serverMayRead;
- // eslint-disable-next-line no-unused-vars
- for await (const _ of stream) { /* reading extends the window */ }
+ // Reading extends the window
+ await dump(stream);
};
}, {
alpn: 'foo',
diff --git a/test/parallel/test-quic-perf-hooks.mjs b/test/parallel/test-quic-perf-hooks.mjs
index fb9f90c5f47..256283acef3 100644
--- a/test/parallel/test-quic-perf-hooks.mjs
+++ b/test/parallel/test-quic-perf-hooks.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall, mustCallAtLeast } from '../common/index.mjs';
import assert from 'node:assert';
import { PerformanceObserver } from 'node:perf_hooks';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -53,7 +54,7 @@ const stream = await clientSession.createBidirectionalStream({
body: encoder.encode('perf test'),
});
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise, clientSession.closed]);
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-session-application-options.mjs b/test/parallel/test-quic-session-application-options.mjs
index b119207bcc1..a97b654e98b 100644
--- a/test/parallel/test-quic-session-application-options.mjs
+++ b/test/parallel/test-quic-session-application-options.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -92,8 +93,7 @@ assert.strictEqual(clientOpts.enableDatagrams, customAppOptions.enableDatagrams)
const stream = await clientSession.createBidirectionalStream();
stream.writer.endSync();
-// eslint-disable-next-line no-unused-vars
-for await (const _ of stream) { /* drain */ }
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
// After close, applicationOptions should return null.
diff --git a/test/parallel/test-quic-session-close-graceful.mjs b/test/parallel/test-quic-session-close-graceful.mjs
index b059b74f832..41bd7481fe3 100644
--- a/test/parallel/test-quic-session-close-graceful.mjs
+++ b/test/parallel/test-quic-session-close-graceful.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -49,7 +50,7 @@ const encoder = new TextEncoder();
// Wait for the stream to complete normally.
await serverDone.promise;
- for await (const batch of stream) { /* drain server FIN */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
// Now the closed promise should resolve.
diff --git a/test/parallel/test-quic-session-initial-rtt.mjs b/test/parallel/test-quic-session-initial-rtt.mjs
index ce24f804dd0..ba40e351c69 100644
--- a/test/parallel/test-quic-session-initial-rtt.mjs
+++ b/test/parallel/test-quic-session-initial-rtt.mjs
@@ -5,6 +5,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -42,7 +43,7 @@ const stream = await clientSession.createBidirectionalStream({
body: payload,
});
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await stream.closed;
await serverDone.promise;
diff --git a/test/parallel/test-quic-session-stats-detailed.mjs b/test/parallel/test-quic-session-stats-detailed.mjs
index 58d769924ec..8ce2e83ed6b 100644
--- a/test/parallel/test-quic-session-stats-detailed.mjs
+++ b/test/parallel/test-quic-session-stats-detailed.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -35,7 +36,7 @@ const data = new Uint8Array(8192);
const stream = await clientSession.createBidirectionalStream();
stream.setBody(data);
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
const stats = clientSession.stats;
diff --git a/test/parallel/test-quic-session-stats.mjs b/test/parallel/test-quic-session-stats.mjs
index b1a6c5aa7f7..26dcf272a86 100644
--- a/test/parallel/test-quic-session-stats.mjs
+++ b/test/parallel/test-quic-session-stats.mjs
@@ -6,6 +6,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -50,7 +51,7 @@ const stream = await clientSession.createBidirectionalStream({
body: payload,
});
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await stream.closed;
await serverDone.promise;
diff --git a/test/parallel/test-quic-session-transport-params.mjs b/test/parallel/test-quic-session-transport-params.mjs
index 6fd92419196..c2417bb999e 100644
--- a/test/parallel/test-quic-session-transport-params.mjs
+++ b/test/parallel/test-quic-session-transport-params.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -118,8 +119,7 @@ assert.ok(clientRemoteParams.initialSCID.length > 0,
const stream = await clientSession.createBidirectionalStream();
stream.writer.endSync();
-// eslint-disable-next-line no-unused-vars
-for await (const _ of stream) { /* drain */ }
+await dump(stream);
await stream.closed;
await serverDone.promise;
diff --git a/test/parallel/test-quic-shared-endpoint-stream-close.mjs b/test/parallel/test-quic-shared-endpoint-stream-close.mjs
index 19e530e50b9..ac070b49fc0 100644
--- a/test/parallel/test-quic-shared-endpoint-stream-close.mjs
+++ b/test/parallel/test-quic-shared-endpoint-stream-close.mjs
@@ -8,6 +8,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -59,7 +60,7 @@ await client1.opened;
const s1 = await client1.createBidirectionalStream({
body: encoder.encode('session1'),
});
-for await (const _ of s1) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(s1);
await s1.closed;
await serverDone1.promise;
@@ -84,7 +85,7 @@ await client2.opened;
const s2 = await client2.createBidirectionalStream({
body: encoder.encode('session2'),
});
-for await (const _ of s2) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(s2);
await s2.closed;
// If the bug is present, this never resolves and the test hangs.
diff --git a/test/parallel/test-quic-stateless-reset.mjs b/test/parallel/test-quic-stateless-reset.mjs
index 90ff9e2c80d..5b20e9453f9 100644
--- a/test/parallel/test-quic-stateless-reset.mjs
+++ b/test/parallel/test-quic-stateless-reset.mjs
@@ -10,6 +10,7 @@
import { hasQuic, skip, mustCall, expectsError, mustNotCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -54,7 +55,7 @@ const encoder = new TextEncoder();
const stream1 = await clientSession.createBidirectionalStream({
body: encoder.encode('hello'),
});
- for await (const _ of stream1) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream1);
await stream1.closed;
// Wait for the server to destroy.
@@ -113,7 +114,7 @@ const encoder = new TextEncoder();
const stream1 = await clientSession.createBidirectionalStream({
body: encoder.encode('hello'),
});
- for await (const _ of stream1) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream1);
await stream1.closed;
await serverDestroyed.promise;
diff --git a/test/parallel/test-quic-stream-bidi-server-initiated.mjs b/test/parallel/test-quic-stream-bidi-server-initiated.mjs
index d2279b28fe5..f5cabd3e737 100644
--- a/test/parallel/test-quic-stream-bidi-server-initiated.mjs
+++ b/test/parallel/test-quic-stream-bidi-server-initiated.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -29,8 +30,7 @@ const serverEndpoint = await listen(mustCall(async (serverSession) => {
body: encoder.encode(message),
});
- // Drain the client's write side (client sends FIN with no data).
- for await (const batch of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}));
diff --git a/test/parallel/test-quic-stream-body-async-iterable.mjs b/test/parallel/test-quic-stream-body-async-iterable.mjs
index 168144689eb..02689c0dee7 100644
--- a/test/parallel/test-quic-stream-body-async-iterable.mjs
+++ b/test/parallel/test-quic-stream-body-async-iterable.mjs
@@ -6,6 +6,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import * as assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -43,7 +44,7 @@ async function* generateChunks() {
const stream = await clientSession.createBidirectionalStream();
stream.setBody(generateChunks());
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-stream-body-pooled-buffer.mjs b/test/parallel/test-quic-stream-body-pooled-buffer.mjs
index 2a98882ac15..0d1ebc0d891 100644
--- a/test/parallel/test-quic-stream-body-pooled-buffer.mjs
+++ b/test/parallel/test-quic-stream-body-pooled-buffer.mjs
@@ -6,6 +6,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -43,7 +44,7 @@ await clientSession.opened;
const stream = await clientSession.createBidirectionalStream();
stream.setBody(expected);
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-stream-body-promise-reject.mjs b/test/parallel/test-quic-stream-body-promise-reject.mjs
index ebfaf98a7bd..24cbeb46e2c 100644
--- a/test/parallel/test-quic-stream-body-promise-reject.mjs
+++ b/test/parallel/test-quic-stream-body-promise-reject.mjs
@@ -6,6 +6,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -42,7 +43,7 @@ const { bytes } = await import('stream/iter');
Promise.resolve(Promise.resolve('nested promise')),
);
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-stream-body-promise.mjs b/test/parallel/test-quic-stream-body-promise.mjs
index 1aab4101d12..f73896b2a95 100644
--- a/test/parallel/test-quic-stream-body-promise.mjs
+++ b/test/parallel/test-quic-stream-body-promise.mjs
@@ -9,6 +9,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -52,7 +53,7 @@ await clientSession.opened;
{
const stream = await clientSession.createBidirectionalStream();
stream.setBody(Promise.resolve('resolved string'));
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
@@ -60,7 +61,7 @@ await clientSession.opened;
{
const stream = await clientSession.createBidirectionalStream();
stream.setBody(Promise.resolve(null));
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
diff --git a/test/parallel/test-quic-stream-body-readable-stream.mjs b/test/parallel/test-quic-stream-body-readable-stream.mjs
index b235610736f..ca98f038ede 100644
--- a/test/parallel/test-quic-stream-body-readable-stream.mjs
+++ b/test/parallel/test-quic-stream-body-readable-stream.mjs
@@ -4,6 +4,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -46,7 +47,7 @@ await clientSession.opened;
});
const stream = await clientSession.createBidirectionalStream();
stream.setBody(rs);
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
@@ -55,7 +56,7 @@ await clientSession.opened;
const readable = Readable.from([encoder.encode(message)]);
const stream = await clientSession.createBidirectionalStream();
stream.setBody(readable);
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
diff --git a/test/parallel/test-quic-stream-body-sources.mjs b/test/parallel/test-quic-stream-body-sources.mjs
index d4f13d84b5c..93218b697f8 100644
--- a/test/parallel/test-quic-stream-body-sources.mjs
+++ b/test/parallel/test-quic-stream-body-sources.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import * as assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -45,7 +46,7 @@ await clientSession.opened;
const buf = encoder.encode(message);
const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
const stream = await clientSession.createBidirectionalStream({ body: ab });
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
@@ -57,7 +58,7 @@ await clientSession.opened;
fullView.set(expectedBytes, offset);
const view = new Uint8Array(backing, offset, expectedBytes.byteLength);
const stream = await clientSession.createBidirectionalStream({ body: view });
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
@@ -69,7 +70,7 @@ await clientSession.opened;
const stream = await clientSession.createBidirectionalStream({ body: sabView });
// The SharedArrayBuffer should still be usable (copied, not transferred).
assert.strictEqual(sab.byteLength, expectedBytes.byteLength);
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
@@ -77,7 +78,7 @@ await clientSession.opened;
{
const blob = new Blob([expectedBytes]);
const stream = await clientSession.createBidirectionalStream({ body: blob });
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
diff --git a/test/parallel/test-quic-stream-body-string.mjs b/test/parallel/test-quic-stream-body-string.mjs
index cfe2790028d..8a9d76aa3e8 100644
--- a/test/parallel/test-quic-stream-body-string.mjs
+++ b/test/parallel/test-quic-stream-body-string.mjs
@@ -4,6 +4,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -35,7 +36,7 @@ await clientSession.opened;
const stream = await clientSession.createBidirectionalStream();
stream.setBody(message);
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-stream-body-sync-iterable.mjs b/test/parallel/test-quic-stream-body-sync-iterable.mjs
index f65cb0da45a..d887a5d4686 100644
--- a/test/parallel/test-quic-stream-body-sync-iterable.mjs
+++ b/test/parallel/test-quic-stream-body-sync-iterable.mjs
@@ -4,6 +4,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -37,7 +38,7 @@ const bodyChunks = chunks.map((c) => encoder.encode(c));
const stream = await clientSession.createBidirectionalStream();
stream.setBody(bodyChunks);
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-stream-closed-promise.mjs b/test/parallel/test-quic-stream-closed-promise.mjs
index 2c30a44fb70..a18aa7f3dd4 100644
--- a/test/parallel/test-quic-stream-closed-promise.mjs
+++ b/test/parallel/test-quic-stream-closed-promise.mjs
@@ -3,6 +3,7 @@
// Test: stream.closed promise resolves after normal completion.
import { hasQuic, skip, mustCall } from '../common/index.mjs';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -32,7 +33,7 @@ const stream = await clientSession.createBidirectionalStream({
body: encoder.encode('normal close'),
});
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
// Closed should resolve (not reject).
await Promise.all([stream.closed, serverDone.promise]);
diff --git a/test/parallel/test-quic-stream-iteration-double.mjs b/test/parallel/test-quic-stream-iteration-double.mjs
index 122d1554559..84bfbb9b387 100644
--- a/test/parallel/test-quic-stream-iteration-double.mjs
+++ b/test/parallel/test-quic-stream-iteration-double.mjs
@@ -8,6 +8,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import * as assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -52,7 +53,7 @@ await clientSession.opened;
const stream = await clientSession.createBidirectionalStream({
body: encoder.encode('double iter test'),
});
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-stream-iteration-pull.mjs b/test/parallel/test-quic-stream-iteration-pull.mjs
index 3dba46c7768..3c296e0d86e 100644
--- a/test/parallel/test-quic-stream-iteration-pull.mjs
+++ b/test/parallel/test-quic-stream-iteration-pull.mjs
@@ -6,6 +6,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -44,7 +45,7 @@ const stream = await clientSession.createBidirectionalStream({
body: encoder.encode(message),
});
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-stream-iteration.mjs b/test/parallel/test-quic-stream-iteration.mjs
index 1f4635d0364..ef35c87f129 100644
--- a/test/parallel/test-quic-stream-iteration.mjs
+++ b/test/parallel/test-quic-stream-iteration.mjs
@@ -9,6 +9,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -70,7 +71,7 @@ for (let i = 0; i < totalStreams; i++) {
const stream = await clientSession.createBidirectionalStream({
body: encoder.encode(message),
});
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
diff --git a/test/parallel/test-quic-stream-limits-pending.mjs b/test/parallel/test-quic-stream-limits-pending.mjs
index 2d81b0d7909..1a450215672 100644
--- a/test/parallel/test-quic-stream-limits-pending.mjs
+++ b/test/parallel/test-quic-stream-limits-pending.mjs
@@ -8,6 +8,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -73,8 +74,7 @@ const s3 = await clientSession.createBidirectionalStream({
assert.strictEqual(s2.pending, true);
assert.strictEqual(opened, 1);
-// Drain and close the first stream.
-for await (const _ of s1) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(s1);
await s1.closed;
const err = new Error('Test error');
@@ -89,7 +89,7 @@ await allDone.promise;
assert.strictEqual(opened, 2);
// s2 should no longer be pending.
-for await (const _ of s2) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(s2);
await s2.closed;
await clientSession.close();
diff --git a/test/parallel/test-quic-stream-many-rapid.mjs b/test/parallel/test-quic-stream-many-rapid.mjs
index 94660889718..d80f94a2041 100644
--- a/test/parallel/test-quic-stream-many-rapid.mjs
+++ b/test/parallel/test-quic-stream-many-rapid.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -47,7 +48,7 @@ for (let i = 0; i < streamCount; i++) {
// Wait for all client streams to close.
await Promise.all(streams.map(async (stream) => {
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}));
diff --git a/test/parallel/test-quic-stream-onblocked.mjs b/test/parallel/test-quic-stream-onblocked.mjs
index b1b9d16c277..891c3a90911 100644
--- a/test/parallel/test-quic-stream-onblocked.mjs
+++ b/test/parallel/test-quic-stream-onblocked.mjs
@@ -12,6 +12,7 @@
import { hasQuic, skip, mustCall, mustCallAtLeast } from '../common/index.mjs';
import assert from 'node:assert';
import dc from 'node:diagnostics_channel';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -61,7 +62,7 @@ stream.onblocked = mustCallAtLeast(() => {
// NGTCP2_ERR_STREAM_DATA_BLOCKED, triggering onblocked.
stream.setBody(body);
-for await (const _ of stream) { /* drain readable side */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await stream.closed;
await serverDone.promise;
diff --git a/test/parallel/test-quic-stream-pending.mjs b/test/parallel/test-quic-stream-pending.mjs
index a51bc711585..b9f4fc58c0d 100644
--- a/test/parallel/test-quic-stream-pending.mjs
+++ b/test/parallel/test-quic-stream-pending.mjs
@@ -6,6 +6,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -49,7 +50,7 @@ await serverDone.promise;
// After the server received data, the stream opened successfully.
// The data arrival proves (pending stream opens after handshake).
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await stream.closed;
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-stream-recv-coalescing.mjs b/test/parallel/test-quic-stream-recv-coalescing.mjs
index c06e7facc83..b493d5eea8e 100644
--- a/test/parallel/test-quic-stream-recv-coalescing.mjs
+++ b/test/parallel/test-quic-stream-recv-coalescing.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -123,8 +124,7 @@ for (let i = 0; i < payloadSizes.length; i++) {
w.endSync();
// Drain the server's empty response to let the stream close cleanly.
-// eslint-disable-next-line no-unused-vars
-for await (const _ of stream) { /* drain response */ }
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-stream-slow-consumer.mjs b/test/parallel/test-quic-stream-slow-consumer.mjs
index 5f1c2d48eb4..58140c948ea 100644
--- a/test/parallel/test-quic-stream-slow-consumer.mjs
+++ b/test/parallel/test-quic-stream-slow-consumer.mjs
@@ -7,6 +7,7 @@
import { hasQuic, skip, mustCall, mustCallAtLeast } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -46,7 +47,7 @@ stream.onblocked = mustCallAtLeast(() => {
stream.setBody(new Uint8Array(dataLength));
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
// The sender should have been blocked multiple times.
diff --git a/test/parallel/test-quic-stream-stats.mjs b/test/parallel/test-quic-stream-stats.mjs
index 1911e1493f4..986142439e4 100644
--- a/test/parallel/test-quic-stream-stats.mjs
+++ b/test/parallel/test-quic-stream-stats.mjs
@@ -6,6 +6,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -59,7 +60,7 @@ const json = stream.stats.toJSON();
assert.ok(json);
assert.strictEqual(typeof json.createdAt, 'string');
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await stream.closed;
await serverDone.promise;
diff --git a/test/parallel/test-quic-stream-write-partial-view.mjs b/test/parallel/test-quic-stream-write-partial-view.mjs
index 0fcd8eea69f..6abec5096cc 100644
--- a/test/parallel/test-quic-stream-write-partial-view.mjs
+++ b/test/parallel/test-quic-stream-write-partial-view.mjs
@@ -8,6 +8,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -64,7 +65,7 @@ assert.ok(source.every((b) => b === 0), 'source mutation should succeed');
writer.endSync();
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-stream-writer-api.mjs b/test/parallel/test-quic-stream-writer-api.mjs
index 6ccd52b046a..352ee29ef59 100644
--- a/test/parallel/test-quic-stream-writer-api.mjs
+++ b/test/parallel/test-quic-stream-writer-api.mjs
@@ -6,6 +6,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import * as assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -44,7 +45,7 @@ await clientSession.opened;
await w.write(encoder.encode('async write'));
const n = w.endSync();
assert.strictEqual(n, 11);
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
@@ -59,7 +60,7 @@ await clientSession.opened;
assert.strictEqual(result, true);
const n = w.endSync();
assert.strictEqual(n, 12);
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
@@ -73,7 +74,7 @@ await clientSession.opened;
]);
const n = w.endSync();
assert.strictEqual(n, 12);
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
@@ -84,7 +85,7 @@ await clientSession.opened;
w.writeSync(encoder.encode('end async'));
const n = await w.end();
assert.strictEqual(n, 9);
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
@@ -122,7 +123,7 @@ await clientSession.opened;
assert.ok(drain === null || drain instanceof Promise);
w.writeSync(encoder.encode('capacity'));
w.endSync();
- for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+ await dump(stream);
await stream.closed;
}
diff --git a/test/parallel/test-quic-stream-zero-length.mjs b/test/parallel/test-quic-stream-zero-length.mjs
index d7af2cf30f0..1c745ffc264 100644
--- a/test/parallel/test-quic-stream-zero-length.mjs
+++ b/test/parallel/test-quic-stream-zero-length.mjs
@@ -6,6 +6,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -33,7 +34,7 @@ await clientSession.opened;
const stream = await clientSession.createBidirectionalStream();
stream.setBody(null);
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
diff --git a/test/parallel/test-quic-writer-async-dispose-ended.mjs b/test/parallel/test-quic-writer-async-dispose-ended.mjs
index 04337343ea8..d309f0eed8c 100644
--- a/test/parallel/test-quic-writer-async-dispose-ended.mjs
+++ b/test/parallel/test-quic-writer-async-dispose-ended.mjs
@@ -5,6 +5,7 @@
// should not fail — it's a no-op.
import { hasQuic, skip, mustCall } from '../common/index.mjs';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -39,7 +40,7 @@ w.endSync();
await w[Symbol.asyncDispose]();
// The stream should close cleanly.
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
diff --git a/test/parallel/test-quic-writer-backpressure.mjs b/test/parallel/test-quic-writer-backpressure.mjs
index 253fc24024e..b9422e917c5 100644
--- a/test/parallel/test-quic-writer-backpressure.mjs
+++ b/test/parallel/test-quic-writer-backpressure.mjs
@@ -8,6 +8,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -73,7 +74,7 @@ w.endSync();
// and 1KB chunks (every 2 chunks fills the buffer).
assert.ok(backpressureCount > 0, 'backpressure should have been hit');
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-writer-write-rejects.mjs b/test/parallel/test-quic-writer-write-rejects.mjs
index b262db692df..3c4d697d7e4 100644
--- a/test/parallel/test-quic-writer-write-rejects.mjs
+++ b/test/parallel/test-quic-writer-write-rejects.mjs
@@ -4,6 +4,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -58,7 +59,7 @@ assert.ok(w.canWrite === true);
await w.write(new Uint8Array(100));
w.endSync();
-for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(stream);
await Promise.all([stream.closed, serverDone.promise]);
await clientSession.close();
await serverEndpoint.close();
diff --git a/test/parallel/test-quic-zero-rtt.mjs b/test/parallel/test-quic-zero-rtt.mjs
index e97c90391bc..47baf3ac732 100644
--- a/test/parallel/test-quic-zero-rtt.mjs
+++ b/test/parallel/test-quic-zero-rtt.mjs
@@ -10,6 +10,7 @@
import { hasQuic, skip, mustCall } from '../common/index.mjs';
import assert from 'node:assert';
+import { dump } from 'node:stream/iter';
if (!hasQuic) {
skip('QUIC is not enabled');
@@ -76,7 +77,7 @@ await Promise.all([gotTicket.promise, gotToken.promise]);
const s1 = await cs1.createBidirectionalStream({
body: encoder.encode('first'),
});
-for await (const _ of s1) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(s1);
await Promise.all([s1.closed, cs1.closed]);
// --- ZRTT-02: Second connection — 0-RTT with ticket + token ---
@@ -98,7 +99,7 @@ assert.strictEqual(info2.earlyDataAttempted, true);
assert.strictEqual(info2.earlyDataAccepted, true);
await s2.writer.end();
-for await (const _ of s2) { /* drain */ } // eslint-disable-line no-unused-vars
+await dump(s2);
await s2.closed;
// Verify the server saw the early data flag.
diff --git a/test/parallel/test-stream-iter-broadcast-basic.js b/test/parallel/test-stream-iter-broadcast-basic.js
index 4384c2b0d6d..232439cdf7d 100644
--- a/test/parallel/test-stream-iter-broadcast-basic.js
+++ b/test/parallel/test-stream-iter-broadcast-basic.js
@@ -4,7 +4,7 @@
const common = require('../common');
const assert = require('assert');
const { setTimeout, setImmediate } = require('timers/promises');
-const { broadcast, text } = require('stream/iter');
+const { broadcast, dump, text } = require('stream/iter');
// =============================================================================
// Basic broadcast
@@ -320,8 +320,7 @@ async function testWriterFailIdempotent() {
// Second call is a no-op (already errored)
writer.fail(new Error('fail2'));
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of consumer) { /* consume */ }
+ await dump(consumer);
}, { message: 'fail!' });
}
diff --git a/test/parallel/test-stream-iter-broadcast-from.js b/test/parallel/test-stream-iter-broadcast-from.js
index cd76f3647b2..b76a2b31b7f 100644
--- a/test/parallel/test-stream-iter-broadcast-from.js
+++ b/test/parallel/test-stream-iter-broadcast-from.js
@@ -3,7 +3,7 @@
const common = require('../common');
const assert = require('assert');
-const { broadcast, Broadcast, from, text } = require('stream/iter');
+const { Broadcast, broadcast, dump, from, text } = require('stream/iter');
const { setImmediate } = require('timers/promises');
// =============================================================================
@@ -172,8 +172,7 @@ async function testBroadcastFromSourceError() {
const { broadcast: bc } = Broadcast.from(failingSource());
const consumer = bc.push();
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of consumer) { /* consume */ }
+ await dump(consumer);
}, { message: 'broadcast source boom' });
}
diff --git a/test/parallel/test-stream-iter-consumers-merge.js b/test/parallel/test-stream-iter-consumers-merge.js
index f3b9ebc24b3..5cbe773ac08 100644
--- a/test/parallel/test-stream-iter-consumers-merge.js
+++ b/test/parallel/test-stream-iter-consumers-merge.js
@@ -4,10 +4,11 @@
const common = require('../common');
const assert = require('assert');
const {
+ dump,
from,
fromSync,
- push,
merge,
+ push,
text,
toAsyncStreamable,
toStreamable,
@@ -100,10 +101,7 @@ async function testMergeSourceError() {
}
await assert.rejects(
async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of merge(goodSource(), badSource())) {
- /* consume */
- }
+ await dump(merge(goodSource(), badSource()));
},
{ message: 'merge source boom' },
);
@@ -391,10 +389,7 @@ async function testMergeCleanupErrorOnly() {
await assert.rejects(
async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of merge(source(), failingReturnSource())) {
- // Consume all - no primary error
- }
+ await dump(merge(source(), failingReturnSource()));
},
{ message: 'cleanup boom' },
);
@@ -417,10 +412,7 @@ async function testMergePrimaryErrorPrecedesCleanupError() {
await assert.rejects(
async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of merge(badSource(), failingReturnSource())) {
- // Consume until error
- }
+ await dump(merge(badSource(), failingReturnSource()));
},
{ message: 'primary boom' },
);
diff --git a/test/parallel/test-stream-iter-consumers-tap.js b/test/parallel/test-stream-iter-consumers-tap.js
index b93f93eb242..a82339d8025 100644
--- a/test/parallel/test-stream-iter-consumers-tap.js
+++ b/test/parallel/test-stream-iter-consumers-tap.js
@@ -4,6 +4,7 @@
const common = require('../common');
const assert = require('assert');
const {
+ dump,
from,
fromSync,
pull,
@@ -85,8 +86,7 @@ async function testTapInPipeline() {
async function testTapAsyncErrorPropagation() {
const badTap = tap(() => { throw new Error('tap error'); });
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of pull(from('hello'), badTap)) { /* consume */ }
+ await dump(pull(from('hello'), badTap));
}, { message: 'tap error' });
}
diff --git a/test/parallel/test-stream-iter-duplex.js b/test/parallel/test-stream-iter-duplex.js
index af2fcb7dd10..d06b394d0aa 100644
--- a/test/parallel/test-stream-iter-duplex.js
+++ b/test/parallel/test-stream-iter-duplex.js
@@ -3,7 +3,7 @@
const common = require('../common');
const assert = require('assert');
-const { duplex, text, bytes } = require('stream/iter');
+const { bytes, dump, duplex, text } = require('stream/iter');
const { setImmediate } = require('timers/promises');
// =============================================================================
@@ -205,8 +205,7 @@ async function testChannelFail() {
const [a, b] = duplex();
a.writer.fail(new Error('channel failed'));
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of b.readable) { /* consume */ }
+ await dump(b.readable);
}, { message: 'channel failed' });
await b.close();
}
diff --git a/test/parallel/test-stream-iter-pull-async.js b/test/parallel/test-stream-iter-pull-async.js
index 452ff3b1734..1a5d1eb2873 100644
--- a/test/parallel/test-stream-iter-pull-async.js
+++ b/test/parallel/test-stream-iter-pull-async.js
@@ -5,6 +5,7 @@ const common = require('../common');
const assert = require('assert');
const {
broadcast,
+ dump,
from,
pull,
push,
@@ -159,10 +160,7 @@ async function testTransformSignalListenerErrorOnSourceError() {
await assert.rejects(
async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of pull(failingSource(), throwingTransform)) {
- // Consume
- }
+ await dump(pull(failingSource(), throwingTransform));
},
{ message: 'source error' },
);
@@ -182,8 +180,7 @@ async function testPullSourceError() {
throw new Error('source boom');
}
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of pull(failingSource())) { /* consume */ }
+ await dump(pull(failingSource()));
}, { message: 'source boom' });
}
@@ -191,8 +188,7 @@ async function testPullSourceError() {
async function testTapCallbackError() {
const badTap = tap(() => { throw new Error('tap boom'); });
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of pull(from('hello'), badTap)) { /* consume */ }
+ await dump(pull(from('hello'), badTap));
}, { message: 'tap boom' });
}
@@ -350,8 +346,7 @@ async function testPullStatelessTransformError() {
throw new Error('async stateless boom');
};
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of pull(from('hello'), badTransform)) { /* consume */ }
+ await dump(pull(from('hello'), badTransform));
}, { message: 'async stateless boom' });
}
@@ -366,8 +361,7 @@ async function testPullStatefulTransformError() {
},
};
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of pull(from('hello'), badStateful)) { /* consume */ }
+ await dump(pull(from('hello'), badStateful));
}, { message: 'async stateful boom' });
}
@@ -405,8 +399,7 @@ async function testPullStatelessTransformFlushError() {
return chunks;
};
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of pull(from('hello'), badFlush)) { /* consume */ }
+ await dump(pull(from('hello'), badFlush));
}, { message: 'async flush boom' });
}
diff --git a/test/parallel/test-stream-iter-push-writer.js b/test/parallel/test-stream-iter-push-writer.js
index bf768fc38cc..a37c5eac2aa 100644
--- a/test/parallel/test-stream-iter-push-writer.js
+++ b/test/parallel/test-stream-iter-push-writer.js
@@ -3,7 +3,7 @@
const common = require('../common');
const assert = require('assert');
-const { push, ondrain, text } = require('stream/iter');
+const { dump, ondrain, push, text } = require('stream/iter');
const { setImmediate } = require('timers/promises');
async function testOndrain() {
@@ -275,8 +275,7 @@ async function testFail() {
// Second fail is a no-op (already errored)
writer.fail(new Error('boom2'));
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of readable) { /* consume */ }
+ await dump(readable);
}, { message: 'boom' });
}
@@ -285,8 +284,7 @@ async function testEndAsyncReturnValue() {
writer.writeSync('hello');
// Start consuming concurrently (end() waits for drain)
const consume = (async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of readable) { /* drain */ }
+ await dump(readable);
})();
const total = await writer.end();
assert.strictEqual(total, 5);
@@ -356,8 +354,7 @@ async function testEndAfterEndSyncWaitsForDrain() {
await Promise.resolve();
assert.strictEqual(ended, false);
- // eslint-disable-next-line no-unused-vars
- for await (const _ of readable) { /* drain */ }
+ await dump(readable);
assert.strictEqual(await end, 5);
}
@@ -557,8 +554,7 @@ async function testEndIdempotentWhenClosed() {
await writer.write('hello');
// Start consuming concurrently (end() waits for drain)
const consume = (async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of readable) { /* drain */ }
+ await dump(readable);
})();
const first = await writer.end();
assert.strictEqual(first, 5);
@@ -577,8 +573,7 @@ async function testAsyncDispose() {
assert.strictEqual(writer.writeSync('fail'), false);
// Drain readable
try {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of readable) { /* consume */ }
+ await dump(readable);
} catch {
// Expected - reader sees the error
}
@@ -610,8 +605,7 @@ async function testSyncDispose() {
assert.strictEqual(writer.writeSync('fail'), false);
// Drain readable
try {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of readable) { /* consume */ }
+ await dump(readable);
} catch {
// Expected
}
diff --git a/test/parallel/test-stream-iter-share-async.js b/test/parallel/test-stream-iter-share-async.js
index ab6bc091479..08fcd0bd338 100644
--- a/test/parallel/test-stream-iter-share-async.js
+++ b/test/parallel/test-stream-iter-share-async.js
@@ -4,6 +4,7 @@
const common = require('../common');
const assert = require('assert');
const {
+ dump,
from,
share,
text,
@@ -327,12 +328,10 @@ async function testShareSourceError() {
const c2 = shared.pull();
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of c1) { /* consume */ }
+ await dump(c1);
}, { message: 'share source boom' });
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const _ of c2) { /* consume */ }
+ await dump(c2);
}, { message: 'share source boom' });
}
diff --git a/test/parallel/test-stream-iter-share-coverage.js b/test/parallel/test-stream-iter-share-coverage.js
index 8b0cc1967f2..fee28ae1568 100644
--- a/test/parallel/test-stream-iter-share-coverage.js
+++ b/test/parallel/test-stream-iter-share-coverage.js
@@ -9,12 +9,13 @@ const assert = require('assert');
const {
Share,
SyncShare,
+ dump,
+ from,
+ fromSync,
share,
- shareSync,
shareProtocol,
+ shareSync,
shareSyncProtocol,
- from,
- fromSync,
text,
textSync,
} = require('stream/iter');
@@ -186,8 +187,7 @@ async function testShareSourceThrowsNonError() {
const shared = share(source());
const consumer = shared.pull();
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const batch of consumer) { /* consume */ }
+ await dump(consumer);
}, (error) => error === reason);
}
diff --git a/test/parallel/test-stream-iter-to-readable.js b/test/parallel/test-stream-iter-to-readable.js
index c96b0c5c12e..8a5f292d2ab 100644
--- a/test/parallel/test-stream-iter-to-readable.js
+++ b/test/parallel/test-stream-iter-to-readable.js
@@ -8,6 +8,7 @@ const common = require('../common');
const assert = require('assert');
const { Writable } = require('stream');
const {
+ dump,
from,
fromSync,
pull,
@@ -100,10 +101,8 @@ async function testErrorAsync() {
const readable = toReadable(gen());
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const chunk of readable) {
- // Consume until error
- }
+ // Consume until error
+ await dump(readable);
}, { message: 'source failed' });
}
@@ -423,10 +422,8 @@ async function testSignalAlreadyAborted() {
const readable = toReadable(gen(), { signal: AbortSignal.abort() });
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const chunk of readable) {
- // Should not receive any data
- }
+ // Should not receive any data
+ await dump(readable);
}, { name: 'AbortError' });
assert.ok(readable.destroyed);
}
@@ -574,10 +571,8 @@ async function testErrorSync() {
const readable = toReadableSync(gen());
await assert.rejects(async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const chunk of readable) {
- // Consume until error
- }
+ // Consume until error
+ await dump(readable);
}, { message: 'sync source failed' });
}
diff --git a/test/parallel/test-stream-iter-transform-output.js b/test/parallel/test-stream-iter-transform-output.js
index 90261a33785..fb0fd2b7ac3 100644
--- a/test/parallel/test-stream-iter-transform-output.js
+++ b/test/parallel/test-stream-iter-transform-output.js
@@ -7,12 +7,13 @@
const common = require('../common');
const assert = require('assert');
const {
- pull,
- pullSync,
bytes,
bytesSync,
+ dump,
from,
fromSync,
+ pull,
+ pullSync,
} = require('stream/iter');
// Stateless transform returns ArrayBuffer (async)
@@ -236,8 +237,7 @@ async function testTransformReturnsInvalidType() {
};
await assert.rejects(
async () => {
- // eslint-disable-next-line no-unused-vars
- for await (const batch of pull(from('x'), tx)) { /* consume */ }
+ await dump(pull(from('x'), tx));
},
{ code: 'ERR_INVALID_ARG_TYPE' },
);