[GH-ISSUE #194] fix(browser): accept page-scoped CDP websocket endpoints #139

Closed
opened 2026-10-15 18:21:34 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @morluto on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/194

Problem

safeBrowserWebSocketUrl in src/browser/CdpEndpoint.ts currently rejects any webSocketDebuggerUrl path that is not browser-scoped (/devtools/browser/*).

In src/browser/CdpEndpoint.ts#L129, discovery validates with pathname.startsWith("/devtools/browser/"). If /json/version returns ws://.../devtools/page/<id>, discoverCdpEndpoint fails with invalid_endpoint_response before any targets can be listed or inspected.

tests/fixtures/fakeCdpBrowser.ts already has an invalidBrowserWebSocket path mode using /devtools/page/not-browser and the existing expectations currently treat this as a hard failure in tests/cdpBrowserProvider.test.ts.

Repro

  1. Start a CDP endpoint where /json/version returns webSocketDebuggerUrl: "ws://localhost:PORT/devtools/page/<id>".
  2. Invoke list_targets or inspect_web_page via CdpBrowserProvider or MCP.
  3. Discovery returns invalid_endpoint_response.

Expected

Accept page-scoped websocket URLs from /json/version (or provide a safe fallback) so compatible CDP providers with page-level sockets can be used.

Impact

Current behavior blocks valid CDP endpoints that expose only page socket URLs, reducing interoperability with nonstandard or proxied browser bridges.

Originally created by @morluto on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/194 ## Problem `safeBrowserWebSocketUrl` in `src/browser/CdpEndpoint.ts` currently rejects any `webSocketDebuggerUrl` path that is not browser-scoped (`/devtools/browser/*`). In `src/browser/CdpEndpoint.ts#L129`, discovery validates with `pathname.startsWith("/devtools/browser/")`. If `/json/version` returns `ws://.../devtools/page/<id>`, `discoverCdpEndpoint` fails with `invalid_endpoint_response` before any targets can be listed or inspected. `tests/fixtures/fakeCdpBrowser.ts` already has an `invalidBrowserWebSocket` path mode using `/devtools/page/not-browser` and the existing expectations currently treat this as a hard failure in `tests/cdpBrowserProvider.test.ts`. ## Repro 1. Start a CDP endpoint where `/json/version` returns `webSocketDebuggerUrl: "ws://localhost:PORT/devtools/page/<id>`". 2. Invoke `list_targets` or `inspect_web_page` via `CdpBrowserProvider` or MCP. 3. Discovery returns `invalid_endpoint_response`. ## Expected Accept page-scoped websocket URLs from `/json/version` (or provide a safe fallback) so compatible CDP providers with page-level sockets can be used. ## Impact Current behavior blocks valid CDP endpoints that expose only page socket URLs, reducing interoperability with nonstandard or proxied browser bridges.
bsakaguchi 2026-10-15 18:21:34 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#139
No description provided.