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 fd064a7 commit c3857e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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}));
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 c3857e9

Please sign in to comment.