Public: anyone can read this; the crew can change it.
Sentinel: The lane has stopped: nothing has merged and nothing said so #16628
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/16627-sentinel-the-lane-has-stopped-nothing-ha → main 0 commits fork
4 files
changed +21
−12
scripts/test-honesty-allow.json −1
| @@ -189,7 +189,6 @@ | ||
| 189 | 189 | "test/footing.test.ts": {"wait":4}, |
| 190 | 190 | "test/forge-archive.test.ts": {"wait":1}, |
| 191 | 191 | "test/forge-cloudflare-celld.test.ts": {"wait":1}, |
| 192 | "test/forge-link-reissue.test.ts": {"wait":1}, | |
| 193 | 192 | "test/forge-origin-oauth.test.ts": {"timeout":1,"wait":1}, |
| 194 | 193 | "test/forge-origin-retry.test.ts": {"timeout":1}, |
| 195 | 194 | "test/forge-origin.test.ts": {"timeout":1}, |
src/git/env.ts +8 −5
| @@ -368,6 +368,14 @@ export async function runGitRaw( | ||
| 368 | 368 | // Timed from before the gate: a wait for a permit is the queue #8158 names. |
| 369 | 369 | const start = performance.now(); |
| 370 | 370 | return gitGate.runUnless(options.signal, async () => { |
| 371 | const timeoutMs = options.timeoutMs ?? 30_000; | |
| 372 | // No time at all, or a caller already gone, never starts a git: one | |
| 373 | // started and then killed could finish first on a loaded machine and | |
| 374 | // succeed past its deadline. | |
| 375 | if (options.signal?.aborted || timeoutMs <= 0) { | |
| 376 | noteGit(gitRecord, args, start); | |
| 377 | return err({ code: STOPPED, stderr: "no time left to run git", args }); | |
| 378 | } | |
| 371 | 379 | let proc: Bun.Subprocess<"pipe" | "ignore", "pipe", "pipe">; |
| 372 | 380 | try { |
| 373 | 381 | proc = Bun.spawn(["git", ...args], { |
| @@ -384,14 +392,9 @@ export async function runGitRaw( | ||
| 384 | 392 | return err(spawnFailure(error, args)); |
| 385 | 393 | } |
| 386 | 394 | |
| 387 | const timeoutMs = options.timeoutMs ?? 30_000; | |
| 388 | 395 | const timer = setTimeout(() => proc.kill("SIGKILL"), timeoutMs); |
| 389 | 396 | const stop = () => proc.kill("SIGKILL"); |
| 390 | 397 | let over = false; |
| 391 | // No time at all is killed now, not on the next turn of the event loop: a | |
| 392 | // timer of 0 fires only once the loop is free, and a busy one lets a small | |
| 393 | // git finish first and succeed past its deadline. | |
| 394 | if (options.signal?.aborted || timeoutMs <= 0) stop(); | |
| 395 | 398 | options.signal?.addEventListener("abort", stop, { once: true }); |
| 396 | 399 | try { |
| 397 | 400 | const [stdout, stderr, code] = await Promise.all([ |
test/forge-link-reissue.test.ts +2 −5
| @@ -14,7 +14,7 @@ import { createToken } from "../src/core/tokens.ts"; | ||
| 14 | 14 | import { createUser, getUserByName } from "../src/core/users.ts"; |
| 15 | 15 | import { createForgeApp } from "../src/tui/forge.ts"; |
| 16 | 16 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 17 | import { settleApp } from "./helpers/tui.ts"; | |
| 17 | import { settleApp, settleUntil } from "./helpers/tui.ts"; | |
| 18 | 18 | import { serve, type Servers } from "../src/http/server.ts"; |
| 19 | 19 | import { firstBoot } from "../src/spawn/first-boot.ts"; |
| 20 | 20 | import { quietLogs } from "./helpers/globals.ts"; |
| @@ -153,10 +153,7 @@ describe("sending a forge's link again", () => { | ||
| 153 | 153 | // nothing changed yet: the link just issued still works |
| 154 | 154 | expect((await claim(before)).status).not.toBe(404); |
| 155 | 155 | k("enter"); |
| 156 | await settleApp(app); | |
| 157 | await Bun.sleep(200); // real-timer: the terminal app settles on its own render loop | |
| 158 | await settleApp(app); | |
| 159 | expect(app.screen.toText()).toContain("/claim#"); | |
| 156 | await settleUntil(app, "/claim#"); | |
| 160 | 157 | expect((await claim(before)).status).toBe(410); |
| 161 | 158 | }); |
| 162 | 159 |
test/git-zero-timeout.test.ts +11 −1
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | import { expect, test } from "bun:test"; |
| 2 | 2 | import { readdirSync, readFileSync } from "node:fs"; |
| 3 | import { runGit } from "../src/git/env.ts"; | |
| 3 | import { runGit, STOPPED } from "../src/git/env.ts"; | |
| 4 | 4 | |
| 5 | 5 | // A deadline of 0 is no time at all (snapshot-repositories' bundleDeadlineMs: () => 0). |
| 6 | 6 | // It was a setTimeout(kill, 0), which fires only when the event loop is next free; a |
| @@ -46,3 +46,13 @@ test("a git given time still runs", async () => { | ||
| 46 | 46 | const r = await runGit(["--version"], { timeoutMs: 30_000 }); |
| 47 | 47 | expect(r.ok).toBe(true); |
| 48 | 48 | }); |
| 49 | ||
| 50 | test("a git given no time, or an aborted caller, never starts one: it fails as stopped", async () => { | |
| 51 | const before = liveGits(); | |
| 52 | const zero = runGit(["--version"], { timeoutMs: 0 }); | |
| 53 | const gone = runGit(["--version"], { signal: AbortSignal.abort() }); | |
| 54 | expect([...liveGits()].filter((pid) => !before.has(pid))).toEqual([]); | |
| 55 | const [a, b] = await Promise.all([zero, gone]); | |
| 56 | expect(a.ok || a.error.code).toBe(STOPPED); | |
| 57 | expect(b.ok || b.error.code).toBe(STOPPED); | |
| 58 | }); |
new above
offline