Skip to content

Commit

Permalink
fixuP
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Nov 18, 2021
1 parent e256132 commit 15adae8
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/internal/streams/writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,17 +734,10 @@ function finishMaybe(stream, state, sync) {
if (needFinish(state)) {
prefinish(stream, state);
if (state.pendingcb === 0) {
state.pendingcb++;
if (sync) {
state.pendingcb++;
process.nextTick((stream, state) => {
if (needFinish(state)) {
finish(stream, state);
} else {
state.pendingcb--;
}
}, stream, state);
} else if (needFinish(state)) {
state.pendingcb++;
process.nextTick(finish);
} else {
finish(stream, state);
}
}
Expand All @@ -753,6 +746,11 @@ function finishMaybe(stream, state, sync) {

function finish(stream, state) {
state.pendingcb--;

if (!needFinish(state)) {
return;
}

state.finished = true;

const onfinishCallbacks = state[kOnFinished].splice(0);
Expand Down

0 comments on commit 15adae8

Please sign in to comment.