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 destroy()
When destroying the stream will be potentially incomplete and
therefore it doesn't make sense to emit finish.
  • Loading branch information
ronag committed Aug 20, 2019
commit 0dc4f9422cff897a62e2eceda2bf192e4d7babd6
3 changes: 2 additions & 1 deletion lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ function needFinish(state) {
state.length === 0 &&
state.bufferedRequest === null &&
!state.finished &&
!state.writing);
!state.writing &&
!state.destroyed);
}
function callFinal(stream, state) {
stream._final((err) => {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-writable-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const assert = require('assert');
write.destroy();

write.removeListener('finish', fail);
write.on('finish', common.mustCall());
write.on('finish', common.mustNotCall());
assert.strictEqual(write.destroyed, true);
}

Expand Down