Version
1.3.0
Steps to reproduce
import { Stagehand } from "@browserbasehq/stagehand";
import { endpointURLString } from "@cloudflare/playwright";
import { z } from "zod";
export default {
async fetch(request, env) {
const stagehand = new Stagehand({
env: "LOCAL",
localBrowserLaunchOptions: { cdpUrl: endpointURLString(env.BROWSER) },
modelName: "google/gemini-3-flash-preview",
modelClientOptions: { apiKey: env.GOOGLE_API_KEY },
verbose: 1,
});
await stagehand.init(); // throws here in production
...
},
} satisfies ExportedHandler<Env>;
put above code into worker
Expected behavior
stagehand.init() resolves and stagehand.page is usable, same as under wrangler dev.
Actual behavior
{
"category": "init",
"message": "connecting to local browser via CDP URL",
"level": 1,
"auxiliary": {
"cdpUrl": {
"value": "http://fake.host/v1/devtools/browser?browser_binding=BROWSER",
"type": "string"
}
}
}
{
"message": "Error in init:",
"level": 0,
"auxiliary": {
"error": {
"value": "TypeError: Cannot read properties of null (reading 'accept')",
"type": "string"
}
}
}
{
"message": "The browser context is undefined. This means the CDP connection to the browser failed. If running locally, please check if the browser is running and the port is open.",
"level": 0
}
Additional context
local isn't affected, but prod environment can't use stagehand
Environment
- `wrangler`: 4.107.0
- `@cloudflare/playwright`: 1.3.0
- `@browserbasehq/stagehand`: 2.5.9
- `wrangler.jsonc`:
{
"compatibility_date": "2026-07-09",
"compatibility_flags": ["nodejs_compat"],
"browser": { "binding": "BROWSER" },
"alias": { "playwright": "@cloudflare/playwright" }
}
- Workers plan: Paid (Browser Rendering requires it)
Version
1.3.0
Steps to reproduce
put above code into worker
Expected behavior
stagehand.init()resolves andstagehand.pageis usable, same as underwrangler dev.Actual behavior
{ "category": "init", "message": "connecting to local browser via CDP URL", "level": 1, "auxiliary": { "cdpUrl": { "value": "http://fake.host/v1/devtools/browser?browser_binding=BROWSER", "type": "string" } } } { "message": "Error in init:", "level": 0, "auxiliary": { "error": { "value": "TypeError: Cannot read properties of null (reading 'accept')", "type": "string" } } } { "message": "The browser context is undefined. This means the CDP connection to the browser failed. If running locally, please check if the browser is running and the port is open.", "level": 0 }Additional context
local isn't affected, but prod environment can't use stagehand
Environment