Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/internal/streams/end-of-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ function eos(stream, opts, callback) {
state &&
state.autoDestroy &&
state.emitClose &&
state.closed === false
state.closed === false &&
(stream.readable === readable && stream.writable === writable)
);

let writableFinished = stream.writableFinished ||
Expand Down
18 changes: 17 additions & 1 deletion test/parallel/test-stream-finished.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -352,3 +352,19 @@ 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();
}