Repository navigation
Description
Summary
$B cookie-import-browser opens a picker UI served by the browse server, but the parent-PID watchdog kills that server shortly after the spawning CLI exits. Users interacting with the picker UI hit Failed to fetch on import.
Repro
$B cookie-import-browser— picker opens athttp://127.0.0.1:<port>/cookie-picker.- Interact with the picker UI (scan domains, search, etc.).
- Click
+to import a domain. - UI shows
Import failed for <domain>: Failed to fetch.
Root cause
Two patches landed close together and their interaction wasn't exercised:
- Parent-PID watchdog added in
browse/src/server.ts:753-768(commit03973c2f, fix: community security wave — 8 PRs, 4 contributors (v0.15.13.0) #847, v0.15.13.0). PollsBROWSE_PARENT_PIDevery 15s and callsshutdown()when the parent is gone. cli.ts:229always setsBROWSE_PARENT_PID = String(process.pid)— i.e., the CLI's own pid. The CLI exits as soon ascookie-import-browserreturns the picker URL, so the next watchdog tick kills the server.- The picker UI's subsequent
fetch()calls then fail. The 30-minIDLE_TIMEOUT_MSnever gets a chance to apply.
The watchdog polls every 15s, so the kill fires 0–15s after the CLI exits. Any picker interaction past that point fails. Likely slipped past testing because a fast click-through (import the first domain in the initial list) can land before the first tick; real use (scanning domains, searching) gives it time to fire.
Proposed fix (by Claude Code)
Let the watchdog skip shutdown while the picker has unexpired codes or sessions. Two-file change:
browse/src/cookie-picker-routes.ts — export state check:
export function hasActivePicker(): boolean {
const now = Date.now();
for (const [code, expiry] of pendingCodes) {
if (expiry > now) return true;
pendingCodes.delete(code);
}
for (const [session, expiry] of validSessions) {
if (expiry > now) return true;
validSessions.delete(session);
}
return false;
}browse/src/server.ts — consult it in the watchdog:
} catch {
if (hasActivePicker()) return;
console.log(`[browse] Parent process ${BROWSE_PARENT_PID} exited, shutting down`);
shutdown();
}Bounded by the existing 1-hour SESSION_TTL_MS, so orphan risk on Windows stays small. Tested locally: server stays up for the picker flow, shuts down normally after session expiry.
Activity
garrytan commentedon Apr 16, 2026
Closing — fixed on main. Same root cause as #943 and #1006. The parent-process watchdog is now disabled in headed/connect/cookie-picker mode.
fix: keep cookie picker alive after cli exits
fix: keep cookie picker alive after cli exits
community wave: 6 PRs + hardening (v0.18.1.0) (#1028)
community wave: 6 PRs + hardening (v0.18.1.0) (garrytan#1028)
community wave: 6 PRs + hardening (v0.18.1.0) (#1028)