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

Fix error.timedOut not working with execa.sync() #249

Merged
merged 2 commits into from May 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -431,7 +431,7 @@ module.exports.sync = (command, args, options) => {
const error = makeError(result, {
joinedCommand,
parsed,
timedOut: false,
timedOut: result.error && result.error.errno === 'ETIMEDOUT',
isCanceled: false,
killed: result.signal !== null
});
Expand Down
6 changes: 6 additions & 0 deletions test.js
Expand Up @@ -393,6 +393,12 @@ test('timeout kills the process if it times out', async t => {
t.true(error.timedOut);
});

test('timeout kills the process if it times out, in sync mode', async t => {
const {killed, timedOut} = await t.throws(() => execa.sync('forever', {timeout: 1, message: TIMEOUT_REGEXP}));
sindresorhus marked this conversation as resolved.
Show resolved Hide resolved
t.false(killed);
t.true(timedOut);
});

test('timeout does not kill the process if it does not time out', async t => {
const error = await execa('delay', ['500'], {timeout: 1e8});
t.false(error.timedOut);
Expand Down