mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
e4bf5dc581
If the destination stream is closed before the source has completed the pipeline should finnish with premature close. Fixes: https://github.com/nodejs/node/issues/43682 PR-URL: https://github.com/nodejs/node/pull/43701 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
22 lines
447 B
JavaScript
22 lines
447 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { pipeline, Duplex, PassThrough } = require('stream');
|
|
const assert = require('assert');
|
|
|
|
const remote = new PassThrough();
|
|
const local = new Duplex({
|
|
read() {},
|
|
write(chunk, enc, callback) {
|
|
callback();
|
|
}
|
|
});
|
|
|
|
pipeline(remote, local, remote, common.mustCall((err) => {
|
|
assert.strictEqual(err.code, 'ERR_STREAM_PREMATURE_CLOSE');
|
|
}));
|
|
|
|
setImmediate(() => {
|
|
remote.end();
|
|
});
|