cloudflare / cloudflare/playwright
[Bug]: TypeError: Cannot read properties of null (reading 'accept') during connectDevtools()
- Dominant language
- TypeScript
- Stars
- 121
- Forks
- 27
- Avg merge
- 2h 35m
- Merged PRs (30d)
- 1
Description
### Version
1.3.0
### Steps to reproduce
```ts
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;
```
put above code into worker
### Expected behavior
`stagehand.init()` resolves and `stagehand.page` is usable, same as under `wrangler dev`.
### Actual behavior
```json
{
"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
```shell
- `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)
```
Contributor guide
Research direction
Start with the `Stagehand.init()` call and the `connectDevtools()` path named in the issue, then compare the production Worker CDP connection with the working `wrangler dev` case. Use the provided Worker setup and versions to investigate; done means `stagehand.init()` resolves in production and `stagehand.page` is usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- playwright, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100