harden e2e getState against transient /api/state 500s (ISS-127)
CI / build + unit + e2e (pull_request) Successful in 9m55s

This commit is contained in:
2026-09-22 17:29:45 +00:00
parent a8c4e93dc1
commit ae91bf6a5d
12 changed files with 89 additions and 33 deletions
+8 -3
View File
@@ -70,9 +70,14 @@ interface StateBody {
const eur = (v: number) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'EUR' }).format(v);
async function getState(page: Page): Promise<StateBody> {
const res = await page.request.get('/api/state');
expect(res.status()).toBe(200);
return (await res.json()) as StateBody;
// ISS-127: /api/state intermittently 500s under scale-1000 dind load; a throw here would
// instantly fail any expect.poll callback, so retry briefly instead.
for (let attempt = 1; ; attempt++) {
const res = await page.request.get('/api/state');
if (res.status() === 200) return (await res.json()) as StateBody;
if (attempt >= 3) throw new Error(`/api/state returned ${res.status()} after 3 attempts`);
await page.waitForTimeout(500);
}
}
// Test hook (FLIGHT_TEST_HOOKS=1): set the world rate and VERIFY from the response that it stuck —