test(windows): read the grandchild pid from accumulated pane output (#33320)

The ConPTY job-ownership proof matched ORCA_GC=<pid> against each onData
chunk, and once gave up after its 20s poll with no pane output to show why.
Two causes are possible: a chunk boundary inside the marker, which per-chunk
matching never recovers from, or a pane that trails the preceding table
stress test. Match the accumulated output and require a non-digit after the
pid, bound the poll at 40s, and include the pane tail if it still fails.
This commit is contained in:
Neil
2026-10-24 20:56:24 -07:00
committed by GitHub
parent aa32d9b9d9
commit fc508bd19e
@@ -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)