{"record":{"id":"7b40cfb6742ef9cd","repo":"grafana/k6","slug":"invalid-websocket-endpoint-q-host-is-missing","errorCode":null,"errorMessage":"invalid WebSocket endpoint %q: host is missing","messagePattern":"invalid WebSocket endpoint %q: host is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/chromium/browser_type.go","lineNumber":170,"sourceCode":"// a missing host, etc.) before we attempt to connect.\nfunc validateWSEndpoint(wsEndpoint string) error {\n\tif strings.TrimSpace(wsEndpoint) == \"\" {\n\t\treturn errors.New(\"WebSocket endpoint cannot be empty\")\n\t}\n\n\tu, err := url.Parse(wsEndpoint)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid WebSocket endpoint %q: %w\", wsEndpoint, err)\n\t}\n\n\tif u.Scheme != \"ws\" && u.Scheme != \"wss\" {\n\t\treturn fmt.Errorf(\n\t\t\t\"invalid WebSocket endpoint %q: scheme must be ws or wss, got %q\", wsEndpoint, u.Scheme,\n\t\t)\n\t}\n\n\tif u.Hostname() == \"\" {\n\t\treturn fmt.Errorf(\"invalid WebSocket endpoint %q: host is missing\", wsEndpoint)\n\t}\n\n\treturn nil\n}\n\n// Connect attaches k6 browser to an existing browser instance.\n//\n// vuCtx is the context coming from the VU itself. The k6 vu/iteration controls\n// its lifecycle.\n//\n// context.background() is used when connecting to an instance of chromium. The\n// connection lifecycle should be handled by the k6 event system.\n//\n// The separation is important to allow for the iteration to end when k6 requires\n// the iteration to end (e.g. during a SIGTERM) and unblocks k6 to then fire off\n// the events which allows the connection to close.\nfunc (b *BrowserType) Connect(ctx, vuCtx context.Context, wsEndpoint string) (*common.Browser, error) {\n\tvuCtx, browserOpts, logger, err := b.init(vuCtx, true, k6ext.GetScenarioOpts(b.vu.Context(), b.vu))","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/chromium/browser_type.go#L152-L188","documentation":"The wsEndpoint URL parsed but contains no host component (e.g. 'ws:///path'). validateWSEndpoint requires a reachable host before connecting; the endpoint is echoed in the message.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/chromium/browser_type.go:170 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include host and port: ws://localhost:9222/devtools/browser/<id>","Verify the browser is running and exposing its DevTools WebSocket"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}