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 e543d35

Browse filesBrowse files
ronagtargos
authored andcommitted
stream: inline and simplify onwritedrain
Inline and simplify onwritedrain. Also remove comment that seems to be outdated/invalid. PR-URL: #29037 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent c396b2a commit e543d35
Copy full SHA for e543d35

File tree

Expand file treeCollapse file tree

1 file changed

+4
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-12
lines changed
Open diff view settings
Collapse file

‎lib/_stream_writable.js‎

Copy file name to clipboardExpand all lines: lib/_stream_writable.js
+4-12Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -478,21 +478,13 @@ function onwrite(stream, er) {
478478
}
479479

480480
function afterWrite(stream, state, finished, cb) {
481-
if (!finished)
482-
onwriteDrain(stream, state);
483-
state.pendingcb--;
484-
cb();
485-
finishMaybe(stream, state);
486-
}
487-
488-
// Must force callback to be called on nextTick, so that we don't
489-
// emit 'drain' before the write() consumer gets the 'false' return
490-
// value, and has a chance to attach a 'drain' listener.
491-
function onwriteDrain(stream, state) {
492-
if (state.length === 0 && state.needDrain) {
481+
if (!finished && state.length === 0 && state.needDrain) {
493482
state.needDrain = false;
494483
stream.emit('drain');
495484
}
485+
state.pendingcb--;
486+
cb();
487+
finishMaybe(stream, state);
496488
}
497489

498490
// If there's something in the buffer waiting, then process it

0 commit comments

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