Skip to content

Commit

Permalink
test: add failing test for duplex backpressure
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelhoral committed Oct 11, 2022
1 parent d5c069b commit 69c7752
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test/parallel/test-stream-duplex-from.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const common = require('../common');
const assert = require('assert');
const { Duplex, Readable, Writable, pipeline } = require('stream');
const { Duplex, Readable, Writable, pipeline, PassThrough, Transform } = require('stream');
const { Blob } = require('buffer');

{
Expand Down Expand Up @@ -148,6 +148,27 @@ const { Blob } = require('buffer');
);
}

// https://github.com/nodejs/node/issues/44925
{
const through = new PassThrough({ objectMode: true });
const stream = Readable.from(['foo', 'bar'], { objectMode: true })
.pipe(Duplex.from({
writable: through,
readable: through
}))
.pipe(new Transform({
objectMode: true,
highWaterMark: 1, // Force backpressure to occur
transform(chunk, encoding, callback) {
callback(null, chunk);
}
}));
stream.toArray()
.then(common.mustCall((values) => {
assert.strictEqual(values.join(' '), 'foo bar');
}));
}

// Ensure that isDuplexNodeStream was called
{
const duplex = new Duplex();
Expand Down

0 comments on commit 69c7752

Please sign in to comment.