()
| 17 | return body; |
| 18 | } |
| 19 | async function createDesktopRun() { |
| 20 | let last; |
| 21 | for (let attempt = 1; attempt <= 3; attempt++) { |
| 22 | try { |
| 23 | return await request("/api/runs", { |
| 24 | method: "POST", |
| 25 | body: JSON.stringify({ repo, verify: ["test -f package.json"], live: true, desktop: true, ttlSeconds: 3600 }), |
| 26 | }); |
| 27 | } catch (error) { |
| 28 | last = error; |
| 29 | const failedId = error?.body?.runId; |
| 30 | if (failedId) await fetch(`${url}/api/runs/${encodeURIComponent(failedId)}`, { method: "DELETE", headers }).catch(() => undefined); |
| 31 | const transient = error?.status === 503 || (error?.status === 500 && error?.body?.error === "runner_error" && /container request failed: 503/i.test(error?.body?.detail ?? "")); |
| 32 | if (!transient || attempt === 3) throw error; |
| 33 | await new Promise((resolve) => setTimeout(resolve, attempt * 5_000)); |
| 34 | } |
| 35 | } |
| 36 | throw last; |
| 37 | } |
| 38 | |
| 39 | const created = await createDesktopRun(); |
| 40 | const runId = created.runId; |
no test coverage detected