fix: respect BROWSE_PARENT_PID=0 from environment#959
Open
garrett-fox wants to merge 1 commit intogarrytan:mainfrom
Open
fix: respect BROWSE_PARENT_PID=0 from environment#959garrett-fox wants to merge 1 commit intogarrytan:mainfrom
garrett-fox wants to merge 1 commit intogarrytan:mainfrom
Conversation
When `BROWSE_PARENT_PID=0` is set in the environment, `startServer()` now passes `0` instead of overriding it with `process.pid`. This lets callers like Claude Code disable the parent-PID watchdog so the daemon survives across short-lived bash invocations. The server already handles this correctly (skips the watchdog when PID is 0), and `pair-agent` already uses this pattern via `extraEnv`. This change extends the same behavior to the general spawn path via an environment variable. The 30-minute idle timeout still handles cleanup for orphaned daemons. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
startServer()always overridesBROWSE_PARENT_PIDwithprocess.pid, ignoring the environment. The parent-PID watchdog then kills the daemon 15 seconds after the spawning CLI process exits.This is correct for interactive use (one long-lived CLI session), but breaks tools like Claude Code where each bash command is a separate short-lived process. The daemon starts, the CLI exits, and 15 seconds later the daemon self-terminates — losing browser state, cookies, and navigation context.
Fix
Check for
BROWSE_PARENT_PID=0in the environment before overriding withprocess.pid. When set to0, the watchdog is skipped (the server already handles this case). The 30-minute idle timeout still cleans up orphaned daemons.This is a 3-line change — extract a
parentPidvariable and use it in both the Windows and macOS/Linux spawn paths.Prior art
The
pair-agentcommand already usesBROWSE_PARENT_PID=0viaextraEnv(cli.ts:988) for the same reason — the server needs to outlive the spawning process. This PR extends the same pattern to the general spawn path via an environment variable.Usage
🤖 Generated with Claude Code