Fix Chrome instance collision by scoping profiles to session IDs#899
Open
Fix Chrome instance collision by scoping profiles to session IDs#899
Conversation
## Summary Fixes an issue where multiple `--session` daemons sharing the same `--profile` path would connect to a single Chrome instance instead of launching separate instances. This caused tab accumulation, navigation timeouts, and unexpected behavior because Chrome enforces a singleton constraint per `--user-data-dir`. ## Changes - **Added session-scoped profile paths**: When both `--session` and `--profile` are specified, the effective Chrome user-data-dir becomes `<profile>/<session>/` instead of just `<profile>/` - **Updated profile handling**: Modified `launch_options_from_env()` and `handle_launch()` to automatically append the session ID as a subdirectory under the base profile path - **Added documentation**: Updated README, CLI help text, and docs to explain the new behavior - **Added unit tests**: Created tests to verify the session-scoped profile path logic This ensures each session gets its own isolated Chrome instance while preserving the benefits of persistent profiles. Sessions without `--profile` continue to work as before with unique temporary directories. Fixes #896
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Only apply session-scoped profile path when --session is explicitly set; using --profile alone no longer silently appends /default/ (breaking change) - Restore unrelated removal of upgrade command docs/help text - Update test to match corrected behavior
| .get("profile") | ||
| .and_then(|v| v.as_str()) | ||
| .map(|s| s.to_string()), | ||
| .map(|s| session_scoped_profile(s, &state.session_id)), |
Contributor
There was a problem hiding this comment.
Suggested change
| .map(|s| session_scoped_profile(s, &state.session_id)), | |
| .map(|s| match env::var("AGENT_BROWSER_SESSION").ok() { | |
| Some(session) => session_scoped_profile(s, &session), | |
| None => s.to_string(), | |
| }), |
handle_launch unconditionally appends session ID to profile paths, breaking backward compatibility when AGENT_BROWSER_SESSION is not set.
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.
Summary
Fixes an issue where multiple
--sessiondaemons sharing the same--profilepath would connect to a single Chrome instance instead of launching separate instances. This caused tab accumulation, navigation timeouts, and unexpected behavior because Chrome enforces a singleton constraint per--user-data-dir.Changes
--sessionand--profileare specified, the effective Chrome user-data-dir becomes<profile>/<session>/instead of just<profile>/launch_options_from_env()andhandle_launch()to automatically append the session ID as a subdirectory under the base profile pathThis ensures each session gets its own isolated Chrome instance while preserving the benefits of persistent profiles. Sessions without
--profilecontinue to work as before with unique temporary directories.Fixes #896