{"record":{"id":"e3f552e7fc0b9c89","repo":"grafana/k6","slug":"connecting-to-chromium-over-cdp-w","errorCode":null,"errorMessage":"connecting to Chromium over CDP: %w","messagePattern":"connecting to Chromium over CDP: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/chromium_mapping.go","lineNumber":28,"sourceCode":")\n\n// mapChromium maps the Chromium browser type API to the JS module.\nfunc mapChromium(vu moduleVU, bt *chromium.BrowserType) mapping {\n\treturn mapping{\n\t\t\"connectOverCDP\": func(wsEndpoint string) *sobek.Promise {\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\titer := vu.State().Iteration\n\n\t\t\t\t// Clone the BrowserType for this call so concurrent\n\t\t\t\t// connectOverCDP calls in the same iteration (e.g., via\n\t\t\t\t// Promise.all) don't race on its mutable state.\n\t\t\t\tconnBT := bt.Clone()\n\n\t\t\t\t// Link the connection to the iteration trace and connect.\n\t\t\t\ttracedCtx := vu.startConnectTrace(vu.Context(), iter)\n\t\t\t\tb, err := connBT.ConnectOverCDP(tracedCtx, wsEndpoint)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"connecting to Chromium over CDP: %w\", err)\n\t\t\t\t}\n\n\t\t\t\t// Register for guaranteed cleanup at IterEnd / Exit.\n\t\t\t\tvu.trackUserManagedBrowser(iter, b)\n\n\t\t\t\treturn mapBrowser(vu, func() (*common.Browser, error) {\n\t\t\t\t\treturn b, nil\n\t\t\t\t}), nil\n\t\t\t})\n\t\t},\n\t}\n}\n","sourceCodeStart":10,"sourceCodeEnd":41,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/browser/chromium_mapping.go#L10-L41","documentation":"Wrapper around chromium.connectOverCDP's underlying connection error: k6 failed to establish the CDP connection to the wsEndpoint URL (e.g. ws://localhost:9222/...). The wrapped error carries the WebSocket/CDP handshake failure — unreachable endpoint, wrong URL, or a non-Chromium/CDP server.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/browser/chromium_mapping.go:28 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the browser is started with remote debugging: chromium --remote-debugging-port=9222","Confirm the wsEndpoint URL points to a valid CDP /devtools/browser endpoint","Check network reachability and TLS settings for remote browser hosts"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}