Files
paseo/packages/desktop/scripts/dev-runner-readiness.mjs
Mohamed Boudra 836f1a9c23 fix(ci): consolidate E2E repairs and wait for Metro readiness (#4858)
* fix(desktop): wait for Metro HTTP readiness before launching Electron

Expo briefly listens while probing port availability. A successful TCP connection can therefore launch Electron before Metro starts and leave it exiting on connection refusal. Require the configured renderer origin to report the running packager status.

* test(ci): consolidate fixture and readiness corrections

Await the connection and UI states each journey owns, isolate Git fixture contents before observation, and hold real Markdown frames at asserted checkpoints. Keep creation completion diagnostics explicit without claiming the original Windows failure is fixed.

* test(desktop): describe Metro readiness through HTTP states

Keep protocol mechanics in the fixture and assert readiness only after a successful packager response. Cover non-success status and unrelated HTTP content without inline synchronization in the test body.
2026-09-14 21:25:38 +02:00

18 lines
670 B
JavaScript

export async function waitForMetro(url, timeoutMs = 60_000) {
const statusUrl = new URL("/status", url);
const deadline = Date.now() + timeoutMs;
while (Date.now() < deadline) {
try {
const response = await fetch(statusUrl, { signal: AbortSignal.timeout(1_000) });
const body = (await response.text()).trim();
if (response.status === 200 && body === "packager-status:running") {
return;
}
} catch {
// Expo temporarily binds the port while checking availability, before Metro starts.
}
await new Promise((resolve) => setTimeout(resolve, 250));
}
throw new Error(`Timed out waiting for Metro at ${url}`);
}