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 b5df084

Browse filesBrowse files
atlowChemiruyadorno
authored andcommitted
child_process: use addAbortListener
PR-URL: #48550 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent f3c4300 commit b5df084
Copy full SHA for b5df084

File tree

Expand file treeCollapse file tree

1 file changed

+5
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-3
lines changed
Open diff view settings
Collapse file

‎lib/child_process.js‎

Copy file name to clipboardExpand all lines: lib/child_process.js
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const {
4242
StringPrototypeIncludes,
4343
StringPrototypeSlice,
4444
StringPrototypeToUpperCase,
45+
SymbolDispose,
4546
} = primordials;
4647

4748
const {
@@ -95,6 +96,7 @@ const {
9596
const MAX_BUFFER = 1024 * 1024;
9697

9798
const isZOS = process.platform === 'os390';
99+
let addAbortListener;
98100

99101
/**
100102
* Spawns a new Node.js process + fork.
@@ -781,9 +783,9 @@ function spawn(file, args, options) {
781783
if (signal.aborted) {
782784
process.nextTick(onAbortListener);
783785
} else {
784-
signal.addEventListener('abort', onAbortListener, { once: true });
785-
child.once('exit',
786-
() => signal.removeEventListener('abort', onAbortListener));
786+
addAbortListener ??= require('events').addAbortListener;
787+
const disposable = addAbortListener(signal, onAbortListener);
788+
child.once('exit', disposable[SymbolDispose]);
787789
}
788790

789791
function onAbortListener() {

0 commit comments

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