Skip to content

Fix Chrome instance collision by scoping profiles to session IDs#899

Open
ctate wants to merge 2 commits intomainfrom
fix/issue-896-1773808432151
Open

Fix Chrome instance collision by scoping profiles to session IDs#899
ctate wants to merge 2 commits intomainfrom
fix/issue-896-1773808432151

Conversation

@ctate
Copy link
Collaborator

@ctate ctate commented Mar 18, 2026

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

## 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
@vercel
Copy link
Contributor

vercel bot commented Mar 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-browser Ready Ready Preview, Comment Mar 18, 2026 5:49am
agent-browser-env-demo Ready Ready Preview, Comment Mar 18, 2026 5:49am

- 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)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Multiple --session daemons sharing same --profile connect to single Chrome, causing tab accumulation and navigation timeout

1 participant