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: allow calling callback before promise
Refs: #39535
  • Loading branch information
ronag committed Nov 10, 2021
commit f8e42d24fc3f65e9239d4851e3ae10871d61f167
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