diff --git a/lib/resolveTaskFn.js b/lib/resolveTaskFn.js index 77b093b1e..dcb6ad1d0 100644 --- a/lib/resolveTaskFn.js +++ b/lib/resolveTaskFn.js @@ -56,8 +56,12 @@ const handleOutput = (command, result, ctx, isError = false) => { * checks the context. */ const interruptExecutionOnError = (ctx, execaChildProcess) => { + let loopIntervalId + async function loop() { if (ctx.errors.size > 0) { + clearInterval(loopIntervalId) + const ids = await pidTree(execaChildProcess.pid) ids.forEach(process.kill) @@ -67,7 +71,7 @@ const interruptExecutionOnError = (ctx, execaChildProcess) => { } } - const loopIntervalId = setInterval(loop, ERROR_CHECK_INTERVAL) + loopIntervalId = setInterval(loop, ERROR_CHECK_INTERVAL) return () => { clearInterval(loopIntervalId)