[feat]: add configurable local CDP debugging port
Merged
SE
10mo ago+9+9+0123456789-0-0-0123456789
this PR was opened on behalf of @dhanushchalicheemala. thanks for the contribution!!
why :
In env: "LOCAL" mode, Stagehand always launches Chrome on a random CDP debugging port. This makes it hard to attach external tools or configure chrome://inspect with a fixed port.
what changed :
- Add an optional
port?: numbertoLocalBrowserLaunchOptions. - Thread this value through to the local Chrome launcher and pass it as the
portoption tochrome-launcher. - Update V3 docs to document
localBrowserLaunchOptions.port.
Usage
const stagehand = new Stagehand({
env: "LOCAL", localBrowserLaunchOptions: { headless: true, port: 9222, }, model: "openai/gpt-4.1-mini", });
Test plan
pnpm --filter @browserbasehq/stagehand run buildpnpm --filter @browserbasehq/stagehand lint(passes)pnpm --filter @browserbasehq/stagehand test:vitest
Summary by cubic
Adds an optional localBrowserLaunchOptions.port to pin the local Chrome CDP debugging port in LOCAL mode. This makes it easy to attach external tools or use chrome://inspect with a fixed port, while keeping the default random port if unset.
- New Features
- Added port?: number to LocalBrowserLaunchOptions and passed it through launchLocalChrome to chrome-launcher.