Public: anyone can read this; the crew can change it.

Sentinel: The lane has stopped: nothing has merged and nothing said so #16628

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/16627-sentinel-the-lane-has-stopped-nothing-ha → main 0 commits fork

  • Merged. scout/16627-sentinel-the-lane-has-stopped-nothing-ha was merged into main as 413df66.

Review

Sign in to review this change.
4 files changed +21 −12
scripts/test-honesty-allow.json −1
@@ -189,7 +189,6 @@
189189 "test/footing.test.ts": {"wait":4},
190190 "test/forge-archive.test.ts": {"wait":1},
191191 "test/forge-cloudflare-celld.test.ts": {"wait":1},
192 "test/forge-link-reissue.test.ts": {"wait":1},
193192 "test/forge-origin-oauth.test.ts": {"timeout":1,"wait":1},
194193 "test/forge-origin-retry.test.ts": {"timeout":1},
195194 "test/forge-origin.test.ts": {"timeout":1},
src/git/env.ts +8 −5
@@ -368,6 +368,14 @@ export async function runGitRaw(
368368 // Timed from before the gate: a wait for a permit is the queue #8158 names.
369369 const start = performance.now();
370370 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 }
371379 let proc: Bun.Subprocess<"pipe" | "ignore", "pipe", "pipe">;
372380 try {
373381 proc = Bun.spawn(["git", ...args], {
@@ -384,14 +392,9 @@ export async function runGitRaw(
384392 return err(spawnFailure(error, args));
385393 }
386394
387 const timeoutMs = options.timeoutMs ?? 30_000;
388395 const timer = setTimeout(() => proc.kill("SIGKILL"), timeoutMs);
389396 const stop = () => proc.kill("SIGKILL");
390397 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();
395398 options.signal?.addEventListener("abort", stop, { once: true });
396399 try {
397400 const [stdout, stderr, code] = await Promise.all([
test/git-zero-timeout.test.ts +11 −1
@@ -1,6 +1,6 @@
11 import { expect, test } from "bun:test";
22 import { readdirSync, readFileSync } from "node:fs";
3 import { runGit } from "../src/git/env.ts";
3 import { runGit, STOPPED } from "../src/git/env.ts";
44
55 // A deadline of 0 is no time at all (snapshot-repositories' bundleDeadlineMs: () => 0).
66 // 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 () => {
4646 const r = await runGit(["--version"], { timeoutMs: 30_000 });
4747 expect(r.ok).toBe(true);
4848 });
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 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs