We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac11264 commit 7d843bbCopy full SHA for 7d843bb
1 file changed
lib/child_process.js
@@ -42,6 +42,7 @@ const {
42
StringPrototypeIncludes,
43
StringPrototypeSlice,
44
StringPrototypeToUpperCase,
45
+ SymbolDispose,
46
} = primordials;
47
48
const {
@@ -95,6 +96,7 @@ const {
95
96
const MAX_BUFFER = 1024 * 1024;
97
98
const isZOS = process.platform === 'os390';
99
+let addAbortListener;
100
101
/**
102
* Spawns a new Node.js process + fork.
@@ -781,9 +783,9 @@ function spawn(file, args, options) {
781
783
if (signal.aborted) {
782
784
process.nextTick(onAbortListener);
785
} else {
- signal.addEventListener('abort', onAbortListener, { once: true });
- child.once('exit',
786
- () => signal.removeEventListener('abort', onAbortListener));
+ addAbortListener ??= require('events').addAbortListener;
787
+ const disposable = addAbortListener(signal, onAbortListener);
788
+ child.once('exit', disposable[SymbolDispose]);
789
}
790
791
function onAbortListener() {
0 commit comments