{"record":{"id":"9674dd2deef5f673","repo":"mastra-ai/mastra","slug":"failed-to-fetch-cdp-version-info-from-versionurl-9674dd","errorCode":null,"errorMessage":"Failed to fetch CDP version info from ${versionUrl}: ${response.status} ${response.statusText}","messagePattern":"Failed to fetch CDP version info from (.+?): (.+?) (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/browser/browser.ts","lineNumber":929,"sourceCode":"    }\n\n    // HTTP URL - fetch /json/version to get the WebSocket URL\n    if (url.startsWith('http://') || url.startsWith('https://')) {\n      const baseUrl = url.replace(/\\/$/, ''); // Remove trailing slash\n      const versionUrl = `${baseUrl}/json/version`;\n\n      this.logger.debug?.(`Resolving WebSocket URL from ${versionUrl}`);\n\n      // Add timeout to prevent hanging on dead endpoints\n      const controller = new AbortController();\n      const timeoutId = setTimeout(() => controller.abort(), 10000);\n\n      try {\n        const response = await fetch(versionUrl, { signal: controller.signal });\n        clearTimeout(timeoutId);\n\n        if (!response.ok) {\n          throw new Error(\n            `Failed to fetch CDP version info from ${versionUrl}: ${response.status} ${response.statusText}`,\n          );\n        }\n\n        const data = (await response.json()) as { webSocketDebuggerUrl?: string };\n        if (!data.webSocketDebuggerUrl) {\n          throw new Error(`No webSocketDebuggerUrl found in CDP version response from ${versionUrl}`);\n        }\n\n        this.logger.debug?.(`Resolved WebSocket URL: ${data.webSocketDebuggerUrl}`);\n        return data.webSocketDebuggerUrl;\n      } catch (error) {\n        clearTimeout(timeoutId);\n        if (error instanceof Error && error.name === 'AbortError') {\n          throw new Error(`Timeout resolving WebSocket URL from ${versionUrl} (10s)`);\n        }\n        throw error;\n      }","sourceCodeStart":911,"sourceCodeEnd":947,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/browser/browser.ts#L911-L947","documentation":"When connecting to an external CDP endpoint given as an http(s) URL, the browser queries <host>/json/version to discover the webSocketDebuggerUrl. If the HTTP response is not ok, it throws with the status code and status text. This means the endpoint answered but rejected the request.","triggerScenarios":"The CDP URL points at a host/port where /json/version returns 4xx/5xx — e.g. a proxy requiring auth, a DevTools endpoint bound to a different path, a port occupied by a non-Chrome service, or a remote debugging endpoint returning 502/503.","commonSituations":"Chrome launched without --remote-debugging-port but something else listens on that port; reverse proxy rules not forwarding /json/version; connecting to a containerized Chrome through an ingress that blocks the endpoint; TLS mismatch producing a gateway error.","solutions":["Verify Chrome was launched with --remote-debugging-port=<port> and curl the same versionUrl from the app host.","Fix proxy/ingress rules so /json/version is forwarded and returns 200.","Use the correct protocol prefix (ws:// / wss:// for direct WebSocket, http(s) only for the version endpoint).","Check the port isn't claimed by another process."],"exampleFix":"// before\nawait browser.connectToExternalCdp('https://my-proxy.example.com/chrome'); // 404 on /json/version\n// after\nawait browser.connectToExternalCdp('ws://127.0.0.1:9222/devtools/browser/<id>'); // direct ws URL","handlingStrategy":"fallback","validationCode":"// probe the version endpoint before attaching\nconst res = await fetch(versionUrl.replace(/\\/$/, '') + '/json/version');\nif (!res.ok) throw new Error(`CDP version endpoint unhealthy: ${res.status}`);","typeGuard":"function isCdpVersionOk(d: unknown): d is { webSocketDebuggerUrl: string } {\n  return typeof d === 'object' && d !== null && 'webSocketDebuggerUrl' in d && typeof (d as any).webSocketDebuggerUrl === 'string';\n}","tryCatchPattern":"try {\n  await browser.connectToExternalCdp(versionUrl);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Failed to fetch CDP version info')) {\n    // fall back to constructing the ws URL directly\n    await browser.connectToExternalCdp(versionUrl.replace(/^http/, 'ws').replace(/\\/$/, '') + '/devtools/browser');\n  } else throw err;\n}","preventionTips":["curl /json/version from the app host before wiring up CDP attach.","Ensure proxies forward the version endpoint untouched.","Prefer passing a ws:// URL directly when you already know it.","Verify the port isn't occupied by a non-Chrome service."],"tags":["cdp","http","network"],"backgroundTag":"cdp-version-endpoint-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}