diff --git a/tests/integration/resilience-http-e2e.test.ts b/tests/integration/resilience-http-e2e.test.ts index e0b10cc0da..d1d42c7439 100644 --- a/tests/integration/resilience-http-e2e.test.ts +++ b/tests/integration/resilience-http-e2e.test.ts @@ -183,7 +183,8 @@ function createFakeOpenAiRelay() { function createServerProcess(dataDir: string, port: number) { const stdoutLines: string[] = []; const stderrLines: string[] = []; - const child = spawn(process.execPath, ["scripts/run-next.mjs", "dev"], { + let exitInfo: { code: number | null; signal: NodeJS.Signals | null } | null = null; + const child = spawn(process.execPath, ["scripts/run-next-playwright.mjs", "dev"], { cwd: REPO_ROOT, env: { ...process.env, @@ -201,10 +202,14 @@ function createServerProcess(dataDir: string, port: number) { OMNIROUTE_DISABLE_TOKEN_HEALTHCHECK: "true", OMNIROUTE_DISABLE_LOCAL_HEALTHCHECK: "true", OMNIROUTE_HIDE_HEALTHCHECK_LOGS: "true", + OMNIROUTE_E2E_BOOTSTRAP_MODE: "open", }, stdio: ["ignore", "pipe", "pipe"], }); + child.once("exit", (code, signal) => { + exitInfo = { code, signal }; + }); child.stdout.on("data", (chunk) => { const lines = String(chunk).split(/\r?\n/).filter(Boolean); stdoutLines.push(...lines); @@ -221,16 +226,35 @@ function createServerProcess(dataDir: string, port: number) { stdoutLines, stderrLines, baseUrl: `http://127.0.0.1:${port}`, + get exitInfo() { + return exitInfo; + }, }; } async function waitForServer( baseUrl: string, - logs: { stdoutLines: string[]; stderrLines: string[] } + logs: { + stdoutLines: string[]; + stderrLines: string[]; + exitInfo?: { code: number | null; signal: NodeJS.Signals | null } | null; + } ) { const startedAt = Date.now(); let lastError = ""; while (Date.now() - startedAt < 120_000) { + if (logs.exitInfo) { + throw new Error( + [ + `OmniRoute exited before it became ready (code=${logs.exitInfo.code}, signal=${logs.exitInfo.signal})`, + "--- stdout ---", + ...logs.stdoutLines.slice(-40), + "--- stderr ---", + ...logs.stderrLines.slice(-40), + ].join("\n") + ); + } + try { const response = await fetch(`${baseUrl}/api/monitoring/health`, { signal: AbortSignal.timeout(5_000),