Files
orca/tests/e2e/cross-version-wire/release-checkout-process.ts
Brennan Benson c46e84bcc4 test: fix historical compatibility setup reliability (#37905)
Prepare requested immutable historical snapshots before timed extraction and direct reads, using the existing acquisition/process helpers and local-only consumers. Move four suites' historical module setup into per-pin hooks without changing pins, compatibility assertions, workers, extraction/assertion deadlines or publication ownership.

Independent reviews and the binding design settlement passed. The cold comparison and normal uninstrumented final-head CI each passed49files197tests; normal Checkout62s/job276s. All temporary probes removed; brennan-ready READY.

Tracked in STA-13683. Outer-hook failure attribution limitation tracked in STA-13703. No application, saved-data or wire behavior change.
2026-11-03 15:39:06 -08:00

43 lines
1.6 KiB
TypeScript

export const CHECKOUT_PROCESS_TIMEOUT_MS = 45_000
const CHECKOUT_MAX_OUTPUT_BYTES = 1024 * 1024
// Timed consumers must not turn a local read into another network request.
export const LOCAL_RELEASE_GIT_ENV = { GIT_NO_LAZY_FETCH: '1', GIT_TERMINAL_PROMPT: '0' }
export async function runCheckoutProcess(
repoRoot: string,
program: string,
args: string[],
deadline: number,
options: { input?: string; maxOutputBytes?: number; timeoutMs?: number } = {}
): Promise<string> {
const timeoutMs = options.timeoutMs ?? CHECKOUT_PROCESS_TIMEOUT_MS
const operation = args.includes('fetch') ? 'fetch' : (args[0] ?? '')
const remaining = deadline - Date.now()
if (remaining <= 0) {
throw new Error(`${program} ${operation} timed out after ${timeoutMs}ms`)
}
// Kept lazy so plain Node 24 contention children never load Vite's TS graph.
const { runProcess } = await import('@orca/process-host')
const result = await runProcess({
program,
args,
cwd: repoRoot,
env: { ...process.env, ...LOCAL_RELEASE_GIT_ENV },
timeoutMs: Math.max(1, deadline - Date.now()),
maxOutputBytes: options.maxOutputBytes ?? CHECKOUT_MAX_OUTPUT_BYTES,
killOnOutputLimit: true,
input: options.input,
terminationBarrier: true
})
if (result.code === 0 && !result.timedOut && !result.outputTruncated) {
return result.stdout
}
const detail = result.timedOut
? `timed out after ${timeoutMs}ms`
: result.outputTruncated
? 'exceeded output limit'
: result.stderr.trim() || `exited with ${result.code}`
throw new Error(`${program} ${operation} ${detail}`)
}