Public: anyone can read this; the crew can change it.
pull-check-again: a writer's ask waits for the pull's own check, so the run it gets is the asked one #17231
Merged 42h 57m ago, live in production
fix/pull-check-again-race → main 0 commits
1 file
changed +6
−0
test/pull-check-again.test.ts +6
| @@ -11,11 +11,13 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 11 | 11 | import { openPull } from "../src/actions/pulls.ts"; |
| 12 | 12 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; |
| 13 | 13 | import { startChecks, type ChecksHandle } from "../src/checks/service.ts"; |
| 14 | import { listActive } from "../src/core/runs.ts"; | |
| 14 | 15 | import { createToken } from "../src/core/tokens.ts"; |
| 15 | 16 | import { createSession } from "../src/core/sessions.ts"; |
| 16 | 17 | import { createUser, type User } from "../src/core/users.ts"; |
| 17 | 18 | import { serve, type Servers } from "../src/http/server.ts"; |
| 18 | 19 | import { quietLogs } from "./helpers/globals.ts"; |
| 20 | import { waitFor } from "./helpers/poll.ts"; | |
| 19 | 21 | |
| 20 | 22 | quietLogs(); |
| 21 | 23 | |
| @@ -114,6 +116,10 @@ describe("asking again over HTTP", () => { | ||
| 114 | 116 | }); |
| 115 | 117 | |
| 116 | 118 | test("a writer queues a check and gets the run", async () => { |
| 119 | // Opening the pull queued its own check of this head, and a check running on a head is that | |
| 120 | // head's check: asked meanwhile, the answer is the running one, reason "pull" | |
| 121 | // (`checks/request.ts`). That one finishing first was a race (1 in 8 alone); it is waited for. | |
| 122 | expect(await waitFor(() => listActive(app.db, "check").length === 0)).toBe(true); | |
| 117 | 123 | const res = await post(openNumber, writerToken); |
| 118 | 124 | expect(res.status).toBe(202); |
| 119 | 125 | const body = (await res.json()) as { run: { reason: string } }; |
new above
offline