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 b98cc51

Browse filesBrowse files
Trottdanielleadams
authored andcommitted
child_process: reduce abort handler code duplication
Move duplicate abort handler logic into a separate function. PR-URL: #36644 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
1 parent 78d4d91 commit b98cc51
Copy full SHA for b98cc51

File tree

Expand file treeCollapse file tree

1 file changed

+9
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-8
lines changed
Open diff view settings
Collapse file

‎lib/child_process.js‎

Copy file name to clipboardExpand all lines: lib/child_process.js
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ function execFile(file /* , args, options, callback */) {
368368
}
369369
}
370370

371+
function abortHandler() {
372+
if (!ex)
373+
ex = new AbortError();
374+
process.nextTick(() => kill());
375+
}
376+
371377
if (options.timeout > 0) {
372378
timeoutId = setTimeout(function delayedKill() {
373379
kill();
@@ -376,16 +382,11 @@ function execFile(file /* , args, options, callback */) {
376382
}
377383
if (options.signal) {
378384
if (options.signal.aborted) {
379-
if (!ex)
380-
ex = new AbortError();
381-
process.nextTick(() => kill());
385+
process.nextTick(abortHandler);
382386
} else {
383387
const childController = new AbortController();
384-
options.signal.addEventListener('abort', () => {
385-
if (!ex)
386-
ex = new AbortError();
387-
kill();
388-
}, { signal: childController.signal });
388+
options.signal.addEventListener('abort', abortHandler,
389+
{ signal: childController.signal });
389390
child.once('close', () => childController.abort());
390391
}
391392
}

0 commit comments

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