From cc7b829f605c2204441c48a726f4ef7941809579 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Fri, 9 Aug 2019 10:00:00 +0200 Subject: [PATCH] Fix errors being thrown when `detached: true` or `cleanup: false` is used --- lib/kill.js | 2 +- test/fixtures/sub-process-exit | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/kill.js b/lib/kill.js index c23d6a5ad5..dc1c77c384 100644 --- a/lib/kill.js +++ b/lib/kill.js @@ -85,7 +85,7 @@ const setupTimeout = (spawned, {timeout, killSignal = 'SIGTERM'}, spawnedPromise // `cleanup` option handling const setExitHandler = (spawned, {cleanup, detached}, timedPromise) => { if (!cleanup || detached) { - return; + return timedPromise; } const removeExitHandler = onExit(() => { diff --git a/test/fixtures/sub-process-exit b/test/fixtures/sub-process-exit index 2b350a2b66..ea05f0e2d4 100755 --- a/test/fixtures/sub-process-exit +++ b/test/fixtures/sub-process-exit @@ -4,4 +4,14 @@ const execa = require('../..'); const cleanup = process.argv[2] === 'true'; const detached = process.argv[3] === 'true'; -execa('node', ['./test/fixtures/noop'], {cleanup, detached}); + +const runChild = async () => { + try { + await execa('node', ['./test/fixtures/noop'], {cleanup, detached}); + } catch (error) { + console.error(error); + process.exit(1); + } +}; + +runChild();