From d180af6ba29396c1ad7d9ab9f14bdbc2f9537abf Mon Sep 17 00:00:00 2001 From: Hampus Date: Fri, 9 Oct 2026 06:53:50 +0200 Subject: [PATCH] fix(desktop): clean up release check runs on Windows (#3347) --- fluxer_desktop/scripts/release-check.mjs | 36 ++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/fluxer_desktop/scripts/release-check.mjs b/fluxer_desktop/scripts/release-check.mjs index de1d47de4..368617a21 100644 --- a/fluxer_desktop/scripts/release-check.mjs +++ b/fluxer_desktop/scripts/release-check.mjs @@ -309,7 +309,37 @@ async function waitForRenderer({logPath, debugPort, version, timeoutMs, label, c ); } -async function stop(child) { +function killWindowsTree(child, executable) { + for (const args of [ + ['/PID', String(child.pid), '/T', '/F'], + ['/IM', path.basename(executable), '/T', '/F'], + ]) { + try { + execFileSync('taskkill', args, {stdio: 'ignore'}); + } catch {} + } +} + +async function removeSandbox(sandbox) { + for (let attempt = 0; attempt < 20; attempt++) { + try { + fs.rmSync(sandbox, {recursive: true, force: true}); + return; + } catch (error) { + if (attempt === 19) { + process.stderr.write(`could not remove ${sandbox}: ${error.message}\n`); + return; + } + await sleep(500); + } + } +} + +async function stop(child, executable) { + if (process.platform === 'win32') { + killWindowsTree(child, executable); + return; + } if (child.exitCode != null || child.signalCode != null) return; const exited = new Promise((resolve) => { child.once('exit', resolve); @@ -394,9 +424,9 @@ async function run() { result.shellStillRunning = child.exitCode == null && child.signalCode == null; result.ok = true; } finally { - await stop(child); + await stop(child, executable); if (!options.keep) { - fs.rmSync(sandbox, {recursive: true, force: true}); + await removeSandbox(sandbox); } } process.stdout.write(`${JSON.stringify(result, null, '\t')}\n`);