From c3857e93f75b6f4f352debb52f9313938ad40d3e Mon Sep 17 00:00:00 2001 From: ehmicky Date: Tue, 14 May 2019 17:55:55 +0200 Subject: [PATCH] Fix error.timedOut with execa.sync() --- index.js | 2 +- test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 1ca516a857..271c93db73 100644 --- a/index.js +++ b/index.js @@ -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 }); diff --git a/test.js b/test.js index bcc850aac8..c19c17655d 100644 --- a/test.js +++ b/test.js @@ -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);