Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 23ba088

Browse filesBrowse files
ronagMylesBorins
authored andcommitted
stream: don't emit 'finish' after 'error'
Backport-PR-URL: #32372 PR-URL: #32275 Refs: #28710 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Backport-PR-URL: #32372
1 parent 471a5d8 commit 23ba088
Copy full SHA for 23ba088

File tree

Expand file treeCollapse file tree

2 files changed

+3
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-0
lines changed
Open diff view settings
Collapse file

‎lib/_stream_writable.js‎

Copy file name to clipboardExpand all lines: lib/_stream_writable.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,8 @@ function finishMaybe(stream, state) {
647647
if (need) {
648648
prefinish(stream, state);
649649
if (state.pendingcb === 0) {
650+
if (state.errorEmitted)
651+
return;
650652
state.finished = true;
651653
stream.emit('finish');
652654

Collapse file

‎test/parallel/test-stream-writable-write-writev-finish.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-writable-write-writev-finish.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ const stream = require('stream');
132132
process.nextTick(cb);
133133
};
134134
w.on('error', common.mustCall());
135+
w.on('finish', common.mustNotCall());
135136
w.on('prefinish', () => {
136137
w.write("shouldn't write in prefinish listener");
137138
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.