browser-search
browser-search copied to clipboard
smart-extract hangs and loses results when Camofox gets stuck after a session destroy
Problem
When Camofox gets stuck, smart-extract.mjs keeps retrying on a dead server and, once killed by an outer timeout, prints nothing, even for URLs it had already extracted successfully.
Observed on Raspberry Pi 5 with Camofox 1.18.1:
- Two pages were extracted fine (Readability in ~25 ms).
- A third page (a forum behind a Cloudflare challenge) crashed the page:
evaluate failed: Target page, context or browser has been closed, followed bydestroying session. - From then on every
POST /tabshung and failed withtab create timed out after 30000ms(7 consecutive requests, across two separatesmart-extractruns), while/healthkept reportingbrowserRunning: true, browserConnected: true. - The server only recovered when the idle shutdown killed the browser a few minutes later.
The skill made it worse:
camofox.mjsonly recovers from503; the stuck state returns500(the body is justInternal server error, the real reason is masked by the server), so no recovery was attempted.smart-extract.mjshas no notion of a stuck Camofox: every remaining URL goes through readability (45s) -> snapshot (30s) -> tab open (15s).- JSON is written only at the very end, so the two URLs already extracted were lost when the 120s outer timeout killed the process.
Fix
camofox.mjs: after a500onPOST /tabs, probe the browser by openinghttp://example.comwith a short client timeout (camofox-client.mjscreateTabgets an optionaltimeoutMs). If the probe works, the problem is the URL (dead domain, slow site) and nothing is restarted. If it fails, the browser is stopped (/stop, withdocker restartas fallback), restarted, and the tab creation is retried once. If the restart itself fails, the error carries acamofox_stuckmarker.smart-extract.mjs: oncamofox_stuck, skip Camofox for the remaining URLs (the existing escalation to CloakBrowser applies). On SIGTERM/SIGINT, print the results already collected asmode: "partial"instead of exiting silently.SKILL.md: short note on what to do after a timeout or apartialresult.
Verification
- Dead domain followed by a normal URL: no restart, normal URL extracted via Camofox.
- Browser process frozen with
SIGSTOP: probe fails, browser restarted, both URLs extracted (~60s total). timeout -s TERM 5 ...:mode: "partial"with the URLs already extracted.
Known limits
- The stuck state was simulated by freezing the browser process; the original page crash is no longer reproducible on demand.
/stopcloses sessions of every Camofox user, but it only runs when the probe has shown the browser is really stuck.- Partial output works on SIGTERM/SIGINT, not SIGKILL; POSIX signal support is limited on Windows.