| 188 | } |
| 189 | |
| 190 | export async function preflight() { |
| 191 | scenario('preflight'); |
| 192 | const api = await fetch(`${API_URL}/`) |
| 193 | .then((r) => r.ok || r.status === 404) |
| 194 | .catch(() => false); |
| 195 | check(`api reachable at ${API_URL}`, !!api); |
| 196 | const worker = await fetch(`${WORKER_URL}/debug/cron`) |
| 197 | .then((r) => r.ok) |
| 198 | .catch(() => false); |
| 199 | check(`worker debug reachable at ${WORKER_URL}`, !!worker); |
| 200 | if (!api || !worker) { |
| 201 | throw new Error('Stack not reachable — start it with `pnpm dev` first.'); |
| 202 | } |
| 203 | if (SESSION_TIMEOUT_MS > 60_000) { |
| 204 | console.warn( |
| 205 | `\n⚠ SESSION_TIMEOUT_MS=${SESSION_TIMEOUT_MS}ms — this run will be slow.\n` + |
| 206 | ' Re-run the stack AND the harness with e.g. SESSION_TIMEOUT_MS=4000.' |
| 207 | ); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | /** Run `fn` over `items` with at most `concurrency` in flight. */ |
| 212 | export async function runPool<T>( |