Skip to content

Commit 2db8a62

Browse files
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. 89 loops across 60 files, plus 32 now redundant eslint-disable directives and comments removed. Only files that already declare --experimental-stream-iter are converted, so no test gains an experimental flag it did not already opt into. That leaves 21 files with the old idiom; converting those 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 <[email protected]>
1 parent 638793e commit 2db8a62

60 files changed

Lines changed: 162 additions & 150 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

test/parallel/test-quic-cc-algorithm.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { hasQuic, skip, mustCall } from '../common/index.mjs';
88
import assert from 'node:assert';
9+
import { dump } from 'node:stream/iter';
910

1011
if (!hasQuic) {
1112
skip('QUIC is not enabled');
@@ -39,7 +40,7 @@ for (const cc of ['reno', 'cubic', 'bbr']) {
3940
body: encoder.encode('congestion control test'),
4041
});
4142

42-
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
43+
await dump(stream);
4344
await Promise.all([stream.closed, serverDone.promise]);
4445

4546
// Verify the session stats show congestion control was active.

test/parallel/test-quic-datagram-multiple.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import { hasQuic, skip, mustCall, mustCallAtLeast } from '../common/index.mjs';
1111
import assert from 'node:assert';
1212
import * as fixtures from '../common/fixtures.mjs';
13+
import { dump } from 'node:stream/iter';
1314

1415
if (!hasQuic) {
1516
skip('QUIC is not enabled');
@@ -72,7 +73,7 @@ for (let i = 0; i < numDatagrams; i++) {
7273
}
7374

7475
// Complete the stream.
75-
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
76+
await dump(stream);
7677
await stream.closed;
7778

7879
// At least some datagrams should have arrived.

test/parallel/test-quic-diagnostics-channel-stream.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { hasQuic, skip, mustCall } from '../common/index.mjs';
1010
import assert from 'node:assert';
1111
import dc from 'node:diagnostics_channel';
12+
import { dump } from 'node:stream/iter';
1213

1314
if (!hasQuic) {
1415
skip('QUIC is not enabled');
@@ -59,7 +60,7 @@ const stream = await clientSession.createBidirectionalStream({
5960
body: encoder.encode('diagnostics test'),
6061
});
6162

62-
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
63+
await dump(stream);
6364

6465
await Promise.all([stream.closed, serverDone.promise, clientSession.closed]);
6566
await serverEndpoint.close();

test/parallel/test-quic-flow-control-blob.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import { hasQuic, skip, mustCall } from '../common/index.mjs';
99
import assert from 'node:assert';
10+
import { dump } from 'node:stream/iter';
1011

1112
if (!hasQuic) {
1213
skip('QUIC is not enabled');
@@ -42,7 +43,7 @@ const stream = await clientSession.createBidirectionalStream({
4243
body: blob,
4344
});
4445

45-
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
46+
await dump(stream);
4647
await Promise.all([stream.closed, serverDone.promise]);
4748
await clientSession.close();
4849
await serverEndpoint.close();

test/parallel/test-quic-flow-control-block-resume.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { hasQuic, skip, mustCall } from '../common/index.mjs';
1010
import assert from 'node:assert';
11+
import { dump } from 'node:stream/iter';
1112

1213
if (!hasQuic) {
1314
skip('QUIC is not enabled');
@@ -43,7 +44,7 @@ await clientSession.opened;
4344
const stream = await clientSession.createBidirectionalStream();
4445
stream.setBody(data);
4546

46-
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
47+
await dump(stream);
4748

4849
await Promise.all([stream.closed, serverDone.promise, clientSession.closed]);
4950

test/parallel/test-quic-flow-control-params.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import { hasQuic, skip, mustCall } from '../common/index.mjs';
1414
import assert from 'node:assert';
15+
import { dump } from 'node:stream/iter';
1516

1617
if (!hasQuic) {
1718
skip('QUIC is not enabled');
@@ -63,7 +64,7 @@ const encoder = new TextEncoder();
6364
}
6465
w.endSync();
6566

66-
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
67+
await dump(stream);
6768
await Promise.all([stream.closed, serverDone.promise]);
6869
await clientSession.close();
6970
await serverEndpoint.close();

test/parallel/test-quic-h3-maxstreamdata-external-buffer-failure.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { hasQuic, skip } from '../common/index.mjs';
88
import { readFile } from 'node:fs/promises';
99
import { setTimeout as sleep } from 'node:timers/promises';
10+
import { dump } from 'node:stream/iter';
1011

1112
if (!hasQuic) {
1213
skip('QUIC is not enabled');
@@ -33,8 +34,8 @@ const serverMayRead = new Promise((resolve) => { letServerRead = resolve; });
3334
const endpoint = await listen((session) => {
3435
session.onstream = async (stream) => {
3536
await serverMayRead;
36-
// eslint-disable-next-line no-unused-vars
37-
for await (const _ of stream) { /* reading extends the window */ }
37+
// Reading extends the window
38+
await dump(stream);
3839
};
3940
}, {
4041
sni: { '*': { keys: [key], certs: [cert] } },

test/parallel/test-quic-key-update-peer.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { hasQuic, skip, mustCall } from '../common/index.mjs';
88
import assert from 'node:assert';
9+
import { dump } from 'node:stream/iter';
910

1011
if (!hasQuic) {
1112
skip('QUIC is not enabled');
@@ -41,7 +42,7 @@ await clientSession.opened;
4142
const stream = await clientSession.createBidirectionalStream({
4243
body: encoder.encode('after key update'),
4344
});
44-
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
45+
await dump(stream);
4546
await Promise.all([stream.closed, serverDone.promise]);
4647

4748
await clientSession.closed;

test/parallel/test-quic-key-update.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import { hasQuic, skip, mustCall } from '../common/index.mjs';
99
import assert from 'node:assert';
10+
import { dump } from 'node:stream/iter';
1011

1112
if (!hasQuic) {
1213
skip('QUIC is not enabled');
@@ -42,7 +43,7 @@ clientSession.updateKey();
4243
const stream = await clientSession.createBidirectionalStream();
4344
stream.setBody(data);
4445

45-
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
46+
await dump(stream);
4647
await Promise.all([stream.closed, serverDone.promise]);
4748
await clientSession.close();
4849
await serverEndpoint.close();

test/parallel/test-quic-max-payload-size.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import { hasQuic, skip, mustCall } from '../common/index.mjs';
99
import assert from 'node:assert';
10+
import { dump } from 'node:stream/iter';
1011

1112
if (!hasQuic) {
1213
skip('QUIC is not enabled');
@@ -38,7 +39,7 @@ async function transferAndGetPacketCount(maxPayloadSize) {
3839

3940
const stream = await clientSession.createBidirectionalStream();
4041
stream.setBody(new Uint8Array(dataLength));
41-
for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
42+
await dump(stream);
4243
await Promise.all([stream.closed, serverDone.promise]);
4344

4445
const pktSent = clientSession.stats.pktSent;

0 commit comments

Comments
 (0)