mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
stream: finished should complete with read-only Duplex
If passed a Duplex where readable or writable has been explicitly disabled then don't assume 'close' will be emitted. Fixes: https://github.com/nodejs/node/issues/32965 PR-URL: https://github.com/nodejs/node/pull/32967 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Mathias Buus <mathiasbuus@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
This commit is contained in:
1 parent
50d28d4b3a
commit
4eb1701edb
2 files changed
+36
-2
No files matched your search
@@ -76,7 +76,9 @@ function eos(stream, opts, callback) {
|
||||
state &&
|
||||
state.autoDestroy &&
|
||||
state.emitClose &&
|
||||
state.closed === false
|
||||
state.closed === false &&
|
||||
isReadable(stream) === readable &&
|
||||
isWritable(stream) === writable
|
||||
);
|
||||
|
||||
let writableFinished = stream.writableFinished ||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const { Writable, Readable, Transform, finished } = require('stream');
|
||||
const { Writable, Readable, Transform, finished, Duplex } = require('stream');
|
||||
const assert = require('assert');
|
||||
const EE = require('events');
|
||||
const fs = require('fs');
|
||||
@@ -352,3 +352,35 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
|
||||
r.push(null);
|
||||
r.destroy();
|
||||
}
|
||||
|
||||
{
|
||||
const d = new Duplex({
|
||||
final(cb) { }, // Never close writable side for test purpose
|
||||
read() {
|
||||
this.push(null);
|
||||
}
|
||||
});
|
||||
|
||||
d.on('end', common.mustCall());
|
||||
|
||||
finished(d, { readable: true, writable: false }, common.mustCall());
|
||||
|
||||
d.end();
|
||||
d.resume();
|
||||
}
|
||||
|
||||
{
|
||||
const d = new Duplex({
|
||||
final(cb) { }, // Never close writable side for test purpose
|
||||
read() {
|
||||
this.push(null);
|
||||
}
|
||||
});
|
||||
|
||||
d.on('end', common.mustCall());
|
||||
|
||||
d.end();
|
||||
finished(d, { readable: true, writable: false }, common.mustCall());
|
||||
|
||||
d.resume();
|
||||
}
|
||||
Reference in new issue
Block a user