diff --git a/src/main/windows/windows-pty-job.win32.test.ts b/src/main/windows/windows-pty-job.win32.test.ts index 26892390fb6..514f0a1ba2e 100644 --- a/src/main/windows/windows-pty-job.win32.test.ts +++ b/src/main/windows/windows-pty-job.win32.test.ts @@ -71,8 +71,11 @@ describeOnWindows('ConPTY job ownership', () => { spawned.push(proc) let grandchildPid: number | null = null + let output = '' proc.onData((chunk) => { - const match = /ORCA_GC=(\d+)/.exec(chunk) + // ConPTY may split the marker across chunks; a trailing non-digit proves the pid is whole. + output += chunk + const match = /ORCA_GC=(\d+)\D/.exec(output) if (match && grandchildPid === null) { grandchildPid = Number(match[1]) } @@ -86,11 +89,12 @@ describeOnWindows('ConPTY job ownership', () => { ].join('') proc.write(`node -e "${script}"\r`) - for (let attempt = 0; attempt < 80 && grandchildPid === null; attempt += 1) { + // The marker usually lands within 3s, but can trail the preceding table stress test; this only bounds a hang. + for (let attempt = 0; attempt < 160 && grandchildPid === null; attempt += 1) { await sleep(250) } if (grandchildPid === null) { - throw new Error('grandchild never reported its pid') + throw new Error(`grandchild never reported its pid: ${JSON.stringify(output.slice(-600))}`) } // Let the shell settle so the pid list is not read mid-spawn. await sleep(1_000)