grafana/k6 · error
connecting to Chromium over CDP
Error message
connecting to Chromium over CDP: %w
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/browser/chromium_mapping.go:28 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/e3f552e7fc0b9c89.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/chromium_mapping.go:28
)
// mapChromium maps the Chromium browser type API to the JS module.
func mapChromium(vu moduleVU, bt *chromium.BrowserType) mapping {
return mapping{
"connectOverCDP": func(wsEndpoint string) *sobek.Promise {
return promise(vu, func() (any, error) {
iter := vu.State().Iteration
// Clone the BrowserType for this call so concurrent
// connectOverCDP calls in the same iteration (e.g., via
// Promise.all) don't race on its mutable state.
connBT := bt.Clone()
// Link the connection to the iteration trace and connect.
tracedCtx := vu.startConnectTrace(vu.Context(), iter)
b, err := connBT.ConnectOverCDP(tracedCtx, wsEndpoint)
if err != nil {
return nil, fmt.Errorf("connecting to Chromium over CDP: %w", err)
}
// Register for guaranteed cleanup at IterEnd / Exit.
vu.trackUserManagedBrowser(iter, b)
return mapBrowser(vu, func() (*common.Browser, error) {
return b, nil
}), nil
})
},
}
}
View on GitHub (pinned to 01ffac6f24)