Skip to content

fix: retry agent-browser open - close/open race kills ~50% of clone runs - #15

Open
gkastanis wants to merge 1 commit into
FreelyGive:mainfrom
gkastanis:fix/browser-daemon-race
Open

fix: retry agent-browser open - close/open race kills ~50% of clone runs#15
gkastanis wants to merge 1 commit into
FreelyGive:mainfrom
gkastanis:fix/browser-daemon-race

Conversation

@gkastanis

Copy link
Copy Markdown

What

agent-browser close tears down the daemon's unix socket, and the next open can arrive before it is recreated, producing Could not configure browser: Failed to connect: No such file or directory (os error 2) and a dead run - most often at the mobile-screenshot step, since job 01 ends with a close and 01b starts with an open.

I measured roughly a 50% failure rate on a bare close-then-open sequence. There are nine open call sites across eight job files, so patching one site just moves the failure. This adds lib/browser.js with a browserOpen() helper that retries with linear backoff (300/600/900ms) and routes all nine call sites through it.

It also switches the invocation to execFileSync argv form (no shell), which fixes 03b-extract-assets.js interpolating the target URL into the shell unquoted - a URL containing $(), backticks, or spaces breaks or executes today.

How I verified

  • Before: 3 dead runs out of 6 full pipeline runs against a real site.
  • After: 0 out of 6; the race still fired on 2 of them and the first retry recovered both.
  • Shell-safety: opened a URL containing $() and backticks through the new helper; it opens as data, nothing executes.
  • node --check passes on all touched files.

…runs

agent-browser close tears down the daemon socket; the next open can arrive
before it is recreated ('Failed to connect: os error 2'). Measured ~50%
failure on a bare close-then-open. New lib/browser.js browserOpen() retries
with linear backoff (300/600/900ms); all nine open call sites across eight
job files route through it. Validated on a live pipeline: 0 failures in 6
runs versus 3 in 6 before. Also fixes 03b-extract-assets interpolating the
URL into the shell unquoted.
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.

1 participant