fix(cli): prevent env-derived flags from triggering implicit re-launch#1395
Open
xiaodankasi wants to merge 1 commit into
Open
fix(cli): prevent env-derived flags from triggering implicit re-launch#1395xiaodankasi wants to merge 1 commit into
xiaodankasi wants to merge 1 commit into
Conversation
Contributor
|
Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
When the daemon is already running, launch-relevant flags read from environment variables (e.g. AGENT_BROWSER_EXECUTABLE_PATH) or config files would cause the CLI to send an implicit launch command on every invocation. Because these env/config-derived options often differ from the original launch (e.g. missing --proxy that was only on the first command), the daemon's hash comparison detects a mismatch and kills the running browser — resulting in a fresh instance at about:blank. The fix gates the implicit launch on whether the user explicitly passed launch-relevant CLI flags (--headed, --proxy, --profile, etc.) using the existing cli_* tracking fields. This preserves the intentional re-launch behavior from vercel-labs#996 (explicit option changes trigger a restart) while preventing env/config values from causing spurious hash mismatches. Fixes vercel-labs#1299
8955b4a to
fb63504
Compare
Author
| // explicitly passed launch-relevant CLI flags (indicating intent to change options). | ||
| // Environment-variable or config-file derived values alone must NOT trigger a | ||
| // re-launch — doing so causes hash mismatches that kill the running browser (#1299). | ||
| let has_explicit_launch_flags = flags.cli_headed |
Contributor
xiaodankasi
commented
May 28, 2026
Author
xiaodankasi
left a comment
There was a problem hiding this comment.
Re: Vercel bot comment about missing cli_color_scheme and cli_engine —
These cli_* tracking fields do not exist in the codebase. flags.rs only defines: cli_headed, cli_executable_path, cli_profile, cli_state, cli_proxy, cli_args, cli_user_agent, cli_allow_file_access, cli_extensions, cli_download_path, and cli_hide_scrollbars.
Adding cli_color_scheme / cli_engine would be a separate enhancement. Also worth noting: color_scheme is not included in launch_hash(), so it does not affect relaunch behavior regardless.
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
When
AGENT_BROWSER_EXECUTABLE_PATH(or other launch-related env vars / config values) is set, every CLI invocation that hits the daemon sends an implicitlaunchcommand — even when the user only runs a read-only action likeget url.Because this second launch omits flags the original launch included (e.g.
--proxy), the computedlaunch_hashdiffers from the running browser's hash, causing the daemon to kill and re-launch the browser. The new browser instance starts atabout:blank, breaking subsequent commands.This was introduced in PR #996 (commit
05d86fa, shipped in v0.24.1) which added hash-based relaunch detection.Root Cause
The launch condition in
main.rschecksflags.executable_path.is_some()(among others), which istruewhenever the env varAGENT_BROWSER_EXECUTABLE_PATHis set — regardless of whether the user explicitly passed--executable-pathon the CLI. This means an env-only configuration silently triggers a launch command on every invocation.Fix
Guard the implicit launch with
has_explicit_launch_flags— a boolean that istrueonly when the user passes launch-relevant flags directly on the CLI (using thecli_*tracking fields introduced in PR #996 itself). When the daemon is already running and no explicit CLI launch flags are present, the launch command is skipped entirely.This preserves PR #996's design intent: users can still explicitly change browser options mid-session with
--headed,--proxy, etc., triggering a hash-aware relaunch. But env/config-derived values alone will no longer cause unintended relaunches.Reproduction
Testing
Verified on Linux (Alibaba Linux, Chrome 140) where
AGENT_BROWSER_EXECUTABLE_PATH=/usr/bin/google-chrome-140:open --proxy→get url(no explicit flags): browser stays alive, returns correct URL ✓open --proxy→get url --proxy(explicit flag): correctly triggers relaunch ✓open --headed→get url: no spurious relaunch ✓Closes #1299