Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
lib: use spawn options for timeout in execFile
  • Loading branch information
fasttime committed May 3, 2022
commit 7dcb204b841b81155205ce48fac0c2a2bdbaa962
18 changes: 2 additions & 16 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,6 @@ function execFile(file, args = [], options, callback) {
...options
};

// Validate the timeout, if present.
validateTimeout(options.timeout);

// Validate maxBuffer, if present.
validateMaxBuffer(options.maxBuffer);

Expand All @@ -317,8 +314,10 @@ function execFile(file, args = [], options, callback) {
cwd: options.cwd,
env: options.env,
gid: options.gid,
killSignal: options.killSignal,
shell: options.shell,
signal: options.signal,
timeout: options.timeout,
uid: options.uid,
windowsHide: !!options.windowsHide,
windowsVerbatimArguments: !!options.windowsVerbatimArguments
Expand All @@ -336,7 +335,6 @@ function execFile(file, args = [], options, callback) {
let stderrLen = 0;
let killed = false;
let exited = false;
let timeoutId;

let ex = null;

Expand All @@ -346,11 +344,6 @@ function execFile(file, args = [], options, callback) {
if (exited) return;
exited = true;

if (timeoutId) {
clearTimeout(timeoutId);
timeoutId = null;
}

if (!callback) return;

// merge chunks
Expand Down Expand Up @@ -423,13 +416,6 @@ function execFile(file, args = [], options, callback) {
}
}

if (options.timeout > 0) {
timeoutId = setTimeout(function delayedKill() {
kill();
timeoutId = null;
}, options.timeout);
}

if (child.stdout) {
if (encoding)
child.stdout.setEncoding(encoding);
Expand Down