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 61415dc

Browse filesBrowse files
committed
lib: defer pausing stdin to the next tick
This is done to match the stream implementation, which also only actually stops reading in the next tick after the `'pause'` event is emitted. PR-URL: #19377 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 9e1dcdc commit 61415dc
Copy full SHA for 61415dc

File tree

Expand file treeCollapse file tree

1 file changed

+13
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-6
lines changed
Open diff view settings
Collapse file

‎lib/internal/process/stdio.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/stdio.js
+13-6Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,22 @@ function setupStdio() {
109109
stdin._handle.readStop();
110110
}
111111

112-
// if the user calls stdin.pause(), then we need to stop reading
113-
// immediately, so that the process can close down.
112+
// If the user calls stdin.pause(), then we need to stop reading
113+
// once the stream implementation does so (one nextTick later),
114+
// so that the process can close down.
114115
stdin.on('pause', () => {
116+
process.nextTick(onpause);
117+
});
118+
119+
function onpause() {
115120
if (!stdin._handle)
116121
return;
117-
stdin._readableState.reading = false;
118-
stdin._handle.reading = false;
119-
stdin._handle.readStop();
120-
});
122+
if (stdin._handle.reading && !stdin._readableState.flowing) {
123+
stdin._readableState.reading = false;
124+
stdin._handle.reading = false;
125+
stdin._handle.readStop();
126+
}
127+
}
121128

122129
return stdin;
123130
}

0 commit comments

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