From a49d5729e19e6828dd9d9765b3ed2787a6c85fcf Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 2 Nov 2023 12:20:41 +0000 Subject: [PATCH] fix: use taskkill to kill stuck coverage process on windows --- src/test/node.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/test/node.js b/src/test/node.js index e8c479fde..d20306eb2 100644 --- a/src/test/node.js +++ b/src/test/node.js @@ -1,3 +1,4 @@ +import os from 'os' import path from 'path' import { fileURLToPath } from 'url' import { execa } from 'execa' @@ -115,9 +116,18 @@ export default async function testNode (argv, execaOptions) { console.warn(kleur.red('!!! Collecting coverage has hung, killing process')) // eslint-disable-line no-console console.warn(kleur.red('!!! See https://github.com/ipfs/aegir/issues/1206 for more information')) // eslint-disable-line no-console killedWhileCollectingCoverage = true - proc.kill('SIGTERM', { - forceKillAfterTimeout: 1000 - }) + + if (os.platform() === 'win32') { + // SIGTERM/SIGKILL doesn't work reliably on windows + execa('taskkill', ['/F', '/pid', `${proc.pid}`]) + .catch(err => { + console.error('Could not kill process with PID', proc.pid, err) // eslint-disable-line no-console + }) + } else { + proc.kill('SIGTERM', { + forceKillAfterTimeout: 1000 + }) + } }, argv.covTimeout).unref() } })