From 167ef92b0a2cea71c16bc606c06c730bac4c6492 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 30 Aug 2026 23:14:56 -0700 Subject: [PATCH] test(windows): avoid killing exited PTY --- ...ndows-shell-preflight-runtime.windows.test.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/providers/windows-shell-preflight-runtime.windows.test.ts b/src/main/providers/windows-shell-preflight-runtime.windows.test.ts index 85512c40458..91f228b6e85 100644 --- a/src/main/providers/windows-shell-preflight-runtime.windows.test.ts +++ b/src/main/providers/windows-shell-preflight-runtime.windows.test.ts @@ -80,8 +80,12 @@ async function runPty(options: { proc.onData((data) => { output += data }) + let exited = false const exitPromise = new Promise((resolve) => { - proc.onExit(({ exitCode }) => resolve(exitCode)) + proc.onExit(({ exitCode }) => { + exited = true + resolve(exitCode) + }) }) let timeout: ReturnType | undefined const timeoutPromise = new Promise((_resolve, reject) => { @@ -102,10 +106,12 @@ async function runPty(options: { if (timeout) { clearTimeout(timeout) } - try { - proc.kill() - } catch { - // The PTY may already have exited. + if (!exited) { + try { + proc.kill() + } catch { + // The PTY may have exited while cleanup was starting. + } } } }