fix(test): kill the four worst fixed sleeps (300s/30s/30s/20s)

- watchdog.test: the 20s blind wait for one production parent-watchdog
  tick becomes BROWSE_PARENT_WATCHDOG_INTERVAL_MS=250 (new env knob in
  server.ts, NaN-safe, production default unchanged) + polls for the
  boot line and the tick's stay-alive log — strictly stronger (the old
  form never proved a tick observed the parent death). 24s → 3.6s.
- stop-dead-daemon / terminal-agent-owner-watchdog: the 300s/30s
  stand-in child lifetimes become stdin-EOF-bound — the child can never
  self-exit mid-test on a slow runner (spurious-failure class) and
  self-reaps instantly if the test dies (no 300s orphans). Node-compat
  stdin APIs (owner-watchdog runs on the Windows lane).
- browser-skill-commands: the sleeper fixture's 30s self-time becomes
  8s (no stdin pipe exists in runToFiles) — far above the 1s product
  timeout it must outlive, below the test ceiling, so a timeout-kill
  regression fails on clean assertions instead of an opaque bun
  timeout; added: stdout must NOT contain 'done'.

45/45 green across the four files + server tripwires.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-29 05:31:02 +00:00
co-authored by Claude Fable 5
parent 73fe950fbf
commit 5c081a355a
5 changed files with 70 additions and 17 deletions
+10 -1
View File
@@ -109,7 +109,16 @@ describe('stop --force-restart on a LIVE daemon', () => {
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'browse-stop-force-'));
const stateFile = path.join(tmpDir, 'browse.json');
// Portable long-lived child standing in for the wedged daemon process.
const wedged = spawn('bun', ['-e', 'await Bun.sleep(300000)'], { stdio: 'ignore' });
// Its lifetime is tied to this test process instead of a fixed sleep: it
// blocks until its stdin (a pipe we hold open) hits EOF. That means it
// can never self-exit mid-test — which would let the "pid is dead"
// assertion below pass without the CLI having killed anything — and it
// reaps itself the moment the test process dies, even on a hard kill
// where the finally block never runs.
const wedged = spawn('bun', ['-e',
"process.stdin.resume(); const bye = () => process.exit(0); "
+ "process.stdin.on('end', bye); process.stdin.on('error', bye); process.stdin.on('close', bye);",
], { stdio: ['pipe', 'ignore', 'ignore'] });
try {
const port = await closedPort();
fs.writeFileSync(stateFile, JSON.stringify({