Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: use spawn options for timeout in execFile #42959

Closed
wants to merge 1 commit into from
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
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