Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: fix _final and 'prefinish' timing #32780

Closed
wants to merge 3 commits into from
Closed
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
Prev Previous commit
fixup: missing needFinish
  • Loading branch information
ronag committed Apr 15, 2020
commit 571eb8893763991da627834bf7260f702ab60edf
7 changes: 3 additions & 4 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,7 @@ function callFinal(stream, state) {
state.pendingcb--;
if (err) {
errorOrDestroy(stream, err, state.sync);
} else {
// Backwards compat. Don't check needFinish() here.
// Some streams assume 'finish' will be emitted
// even if stream has been destroyed.
} else if (needFinish(state)) {
state.prefinished = true;
stream.emit('prefinish');
// Backwards compat. Don't check state.sync here.
Expand Down Expand Up @@ -682,6 +679,8 @@ function finish(stream, state) {
if (state.errorEmitted)
return;

// TODO(ronag): This could occur after 'close' is emitted.

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

Expand Down