{"record":{"id":"f8afaec1e6b22e4a","repo":"mastra-ai/mastra","slug":"failed-to-fetch-cdp-version-info-from-versionurl","errorCode":null,"errorMessage":"Failed to fetch CDP version info from ${versionUrl}: ${response.status} ${response.statusText}","messagePattern":"Failed to fetch CDP version info from (.+?): (.+?) (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"browser/firecrawl/src/resolve-cdp.ts","lineNumber":25,"sourceCode":"): Promise<string> {\n  if (url.startsWith('ws://') || url.startsWith('wss://')) {\n    return url;\n  }\n\n  if (url.startsWith('http://') || url.startsWith('https://')) {\n    const baseUrl = url.replace(/\\/$/, '');\n    const versionUrl = `${baseUrl}/json/version`;\n\n    logger?.debug?.(`Resolving WebSocket URL from ${versionUrl}`);\n\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\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      logger?.debug?.(`Resolved WebSocket URL: ${data.webSocketDebuggerUrl}`);\n      return data.webSocketDebuggerUrl;\n    } catch (error) {\n      if (error instanceof Error && error.name === 'AbortError') {\n        throw new Error(`Timeout resolving WebSocket URL from ${versionUrl} (10s)`);\n      }\n      throw error;\n    } finally {\n      clearTimeout(timeoutId);","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/browser/firecrawl/src/resolve-cdp.ts#L7-L43","documentation":"resolveCdpWebSocketUrl fetches the Chrome DevTools Protocol /json/version endpoint to discover the browser's webSocketDebuggerUrl. If the HTTP response is not OK (non-2xx), the library throws with the target URL and status/statusText. This means the CDP endpoint was reachable enough to answer but rejected the request or reported an error.","triggerScenarios":"Calling new FirecrawlBrowser(...) or accessing the browser's wsUrl when the Firecrawl-provided CDP versionUrl responds with an HTTP error status (401, 403, 404, 500, 502, etc.).","commonSituations":"Expired or invalid Firecrawl API key embedded in the URL; wrong or stale CDP endpoint (browser session already terminated); proxy/gateway errors between client and remote browser; misconfigured apiUrl.","solutions":["Check the response status in the error: 401/403 means auth, 404/410 means the session is gone — create a new browser session","Verify the Firecrawl API key and apiUrl configuration","Retry the connection; if the remote browser was torn down, launch a fresh FirecrawlBrowser","Check network/proxy interference with the versionUrl"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const res = await fetch(versionUrl);\nif (!res.ok) console.error('CDP endpoint unhealthy:', res.status, await res.text());","typeGuard":null,"tryCatchPattern":"try {\n  const browser = new FirecrawlBrowser(config);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Failed to fetch CDP version info')) {\n    // status embedded in message; 401/403 = auth, 404/410 = recreate session\n    await recreateBrowserSession();\n  } else throw e;\n}","preventionTips":["Pre-flight check the /json/version endpoint before constructing the browser","Rotate API keys before expiry; treat 401/403 as auth, 404 as dead session","Recreate browser sessions instead of reusing long-lived CDP URLs","Log response bodies on failure to distinguish proxy vs CDP errors"],"tags":["network","cdp","http-error","browser"],"backgroundTag":"cdp-version-endpoint-error","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}