Skip to content

Commit

Permalink
stream: allow calling callback before promise
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Nov 10, 2021
1 parent 0a62026 commit f8e42d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/internal/streams/destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,14 @@ function constructNT(stream) {
then.call(
result,
function() {
process.nextTick(onConstruct, null);
if (!called) {
process.nextTick(onConstruct, null);
}
},
function(err) {
process.nextTick(onConstruct, err);
if (!called) {
process.nextTick(onConstruct, err);
}
});
}
}
Expand Down
8 changes: 6 additions & 2 deletions lib/internal/streams/writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,14 @@ function callFinal(stream, state) {
then.call(
result,
function() {
process.nextTick(onFinish, null);
if (!called) {
process.nextTick(onFinish, null);
}
},
function(err) {
process.nextTick(onFinish, err);
if (!called) {
process.nextTick(onFinish, err);
}
});
}
}
Expand Down

0 comments on commit f8e42d2

Please sign in to comment.