Skip to content

Commit

Permalink
Fix error.timedOut with execa.sync()
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 14, 2019
1 parent 27d7b1e commit 8ed364d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Expand Up @@ -431,8 +431,9 @@ module.exports.sync = (command, args, options) => {
const error = makeError(result, {
joinedCommand,
parsed,
timedOut: false,
isCanceled: false
timedOut: result.error && result.error.errno === 'ETIMEDOUT',
isCanceled: false,
killed: result.signal !== null
});

if (!parsed.options.reject) {
Expand Down
6 changes: 6 additions & 0 deletions test.js
Expand Up @@ -379,6 +379,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}));
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

0 comments on commit 8ed364d

Please sign in to comment.