Skip to content

Conversation

@elijahr
Copy link

@elijahr elijahr commented Nov 19, 2025

Adds the ability to dynamically switch between browser instances at runtime, with support for both HTTP and WebSocket connection URLs and configurable connection timeouts.

New Features:

  • switch_browser tool for connecting to different browser instances
  • --noLaunch CLI flag to start without auto-launching a browser
  • Timeout parameter with 10-second default for connection attempts
  • Automatic HTTP to WebSocket URL conversion
  • Support for ws://, wss://, http://, and https:// protocols

Implementation:

  • Created src/context.ts to manage browser context lifecycle
  • Created src/config.ts to break dependency cycles
  • Added getBrowser/setBrowser helpers for better testability
  • Added disconnectBrowser() to safely close browser connections
  • Proper timeout cleanup to prevent resource leaks
  • Comprehensive error handling with proper Error type checks

Testing:

  • 6 new integration tests with actual browser instances
  • Tests verify browser disconnection, connection switching, and error handling
  • All tests use headless mode for CI compatibility
  • Proper test isolation with independent browser instances per test

Documentation:

  • Updated README.md with new tool and CLI option
  • Auto-generated tool reference documentation
  • Updated release-please configuration

Adds the ability to dynamically switch between browser instances at runtime,
with support for both HTTP and WebSocket connection URLs and configurable
connection timeouts.

New Features:
- switch_browser tool for connecting to different browser instances
- --noLaunch CLI flag to start without auto-launching a browser
- Timeout parameter with 10-second default for connection attempts
- Automatic HTTP to WebSocket URL conversion
- Support for ws://, wss://, http://, and https:// protocols

Implementation:
- Created src/context.ts to manage browser context lifecycle
- Created src/config.ts to break dependency cycles
- Added getBrowser/setBrowser helpers for better testability
- Added disconnectBrowser() to safely close browser connections
- Proper timeout cleanup to prevent resource leaks
- Comprehensive error handling with proper Error type checks

Testing:
- 6 new integration tests with actual browser instances
- Tests verify browser disconnection, connection switching, and error handling
- All tests use headless mode for CI compatibility
- Proper test isolation with independent browser instances per test

Documentation:
- Updated README.md with new tool and CLI option
- Auto-generated tool reference documentation
- Updated release-please configuration
@google-cla
Copy link

google-cla bot commented Nov 19, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Resolved conflicts between two independent refactorings:
- Our branch: extracted VERSION/args to config.js, added switch_browser tool
- Upstream: added features.js for feature flags, bumped VERSION to 0.10.2

Changes:
- Updated VERSION to 0.10.2 in config.ts
- Added features.js import and conditional issue loading
- Retained all switch_browser tool functionality
- No duplicate code, clean integration

All 203 tests pass.
The convertHttpToBrowserUrl() function previously had no timeout on the
fetch() call, which could cause switch_browser to hang indefinitely when
the target browser was unreachable or unresponsive.

Changes:
- Added AbortController with configurable timeout (default 10s)
- Enhanced error messages to distinguish timeout from connection failures
- Added test coverage for HTTP fetch timeout behavior
- Updated documentation to reflect new timeout parameter

Fixes potential infinite hang when using HTTP URLs with unreachable browsers.
@OrKoN
Copy link
Collaborator

OrKoN commented Nov 20, 2025

Could you please file a feature request instead and provide details about your use case? cc @natorion

@elijahr
Copy link
Author

elijahr commented Nov 20, 2025

@OrKoN Done! #590

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.

2 participants