Skip to content

Commit

Permalink
Remove use of highWatermark option (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored Mar 15, 2024
1 parent 4d233d3 commit 1febc95
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
5 changes: 1 addition & 4 deletions source/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ const getStreamIterable = async function * (stream) {
handleStreamEnd(stream, controller, state);

try {
for await (const [chunk] of nodeImports.events.on(stream, 'data', {
signal: controller.signal,
highWatermark: stream.readableHighWaterMark,
})) {
for await (const [chunk] of nodeImports.events.on(stream, 'data', {signal: controller.signal})) {
yield chunk;
}
} catch (error) {
Expand Down
25 changes: 0 additions & 25 deletions test/stream.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {once} from 'node:events';
import {version} from 'node:process';
import {Readable, Duplex} from 'node:stream';
import {scheduler, setTimeout as pSetTimeout} from 'node:timers/promises';
import test from 'ava';
Expand Down Expand Up @@ -267,30 +266,6 @@ const testMultipleReads = async (t, wait) => {
test('Handles multiple successive fast reads', testMultipleReads, () => scheduler.yield());
test('Handles multiple successive slow reads', testMultipleReads, () => pSetTimeout(100));

// The `highWaterMark` option was added to `once()` by Node 20.
// See https://github.com/nodejs/node/pull/41276
const nodeMajor = version.split('.')[0].slice(1);
if (nodeMajor >= 20) {
test('Pause stream when too much data at once', async t => {
const stream = new Readable({
read: onetime(function () {
this.push('.');
this.push('.');
this.push('.');
this.push('.');
this.push(null);
}),
highWaterMark: 2,
});
const [result] = await Promise.all([
getStream(stream),
once(stream, 'pause'),
]);
t.is(result, '....');
assertSuccess(t, stream, Readable);
});
}

test('Can call twice at the same time', async t => {
const stream = Readable.from(fixtureMultiString);
const [result, secondResult] = await Promise.all([
Expand Down

0 comments on commit 1febc95

Please sign in to comment.