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
Next Next commit
stream: don't emit 'finish' after 'error'
  • Loading branch information
ronag committed Mar 15, 2020
commit 48e7a2e6bcf8c230accdeb86af13f757cc38f12e
4 changes: 4 additions & 0 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,10 @@ function finishMaybe(stream, state, sync) {

function finish(stream, state) {
state.pendingcb--;
if (state.errorEmitted) {
return;
}
Comment thread
ronag marked this conversation as resolved.
Outdated

state.finished = true;
stream.emit('finish');

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-stream-writable-write-writev-finish.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const stream = require('stream');
process.nextTick(cb);
};
w.on('error', common.mustCall());
w.on('finish', common.mustNotCall());
w.on('prefinish', () => {
w.write("shouldn't write in prefinish listener");
});
Expand Down