Skip to content

fix(browser): serve waits for chrome, keeps its stderr, and reaps its own Xvfb (DIVE-4400) - #67

Open
5dive-bot wants to merge 1 commit into
mainfrom
dive-4400-serve-liveness
Open

fix(browser): serve waits for chrome, keeps its stderr, and reaps its own Xvfb (DIVE-4400)#67
5dive-bot wants to merge 1 commit into
mainfrom
dive-4400-serve-liveness

Conversation

@5dive-bot

Copy link
Copy Markdown
Collaborator

DIVE-4400 arm 1 — serve must not print success until Chrome is alive

Measured on our canary (exact-swallow, 2026-09-13 04:0x–04:2xZ):
5dive browser serve linkedin.com printed
serving linkedin.com on :375 (persistent …) and left no Chrome process at
all
— only the Xvfb it started. browser ls listed the site, the stack status
read state=ok / store=ready, and the only surface that told the truth was a
customer pressing Connect on the live dashboard and getting a 502.

bin/browser backgrounded Chrome with >/dev/null 2>&1 &, wrote
chrome_pid=$! unconditionally, printed success, and judged liveness by the
Xvfb pid. A Chrome that dies in the first millisecond was indistinguishable
from a healthy one, and its stderr was discarded before anyone could read it.

This PR

  • serve waits for the pid, kill -0s it after a beat, and on failure exits
    non-zero with Chrome's own stderr (no longer sent to /dev/null).
  • A failed serve reaps the Xvfb it started, so it no longer leaves an
    orphan display that pushes the next _display_free probe to :376, :377, …
    (two such orphans were standing on the canary).
  • The pidfile is deleted on a failed start, so no later caller reads it as live.

Evidence

tests/browser_plugin_unit.sh208 passed / 0 failed (199 before, +9 arms).

Mutants, anchored to individual arms:

  • drop the Xvfb reap → fails exactly T10u …and REAPS THE Xvfb it started
  • restore the old print-and-return shape → fails 6 T10u arms (rc, the success
    line, both stderr lines, the pidfile, the reap)

Controls, because a negative arm that cannot fail is arm-counting: T10u first
runs a Chrome that stays up on the same rig and asserts serve succeeds and
its Xvfb is left running. The fake Xvfb records its own pid (exec keeps
it) — "no display was left behind" cannot be read off the product's pidfile,
because a correct failure deletes that file.

Not claimed

Not re-measured on the canary: that box's Chrome is still broken (a libc6
upgrade pending reboot — the trigger, not the defect) and this host has no
browser stack installed. The on-box re-measure — serve refusing, the row
reading degraded, Connect still 502 but now visibly — is owed and is the
real acceptance for DIVE-4355.

Arm 2 (the stack health row) is 5dive-ai/5dive-api's companion PR.

🤖 Generated with Claude Code

… own Xvfb (DIVE-4400)

`serve` backgrounded chrome with `>/dev/null 2>&1 &`, wrote chrome_pid=$!
unconditionally and printed success. A chrome that trapped in its first
millisecond was therefore indistinguishable from a healthy one to `ls`, to the
stack row and to `viewer` — and the only surface that told the truth was the
customer's Connect press, which 502'd.

- _pid_live: a reaped-pending zombie answers `kill -0` with success, so the one
  moment we need the truth is the one moment kill -0 cannot give it. /proc says Z.
- serve waits, bounded, for the process to still exist before writing a pidfile
  or printing anything; on death it dies E_UNAVAILABLE carrying chrome's own
  stderr (kept in the profile at 0600 instead of discarded).
- a failed serve reaps the Xvfb it started, so it leaves no orphan display for
  _display_free to hop past forever.
- _probe's "UNKNOWN (probe did not load)" now names what chrome said and STAMPS
  the profile, so `ls` can tell it from "never probed".

Tests: tests/browser_plugin_unit.sh T10u — control arm (a chrome that stays up
still serves, its Xvfb left running), then the defect: rc 69, no success line,
chrome's two stderr lines handed back, no pidfile, Xvfb reaped, and the
dashboard's own `viewer` call refusing. 208 passed / 0 failed. Mutants: dropping
the reap fails exactly the orphan arm; restoring the old print-and-return shape
fails six.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants