{"record":{"id":"c068f20e1cc61f26","repo":"grafana/k6","slug":"connecting-to-browser-w","errorCode":null,"errorMessage":"connecting to browser: %w","messagePattern":"connecting to browser: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/chromium/browser_type.go","lineNumber":210,"sourceCode":"\n\tbp, err := b.connect(ctx, vuCtx, wsEndpoint, browserOpts, logger)\n\tif err != nil {\n\t\terr = &k6ext.UserFriendlyError{\n\t\t\tErr:     err,\n\t\t\tTimeout: browserOpts.Timeout,\n\t\t}\n\t\treturn nil, fmt.Errorf(\"%w\", err)\n\t}\n\n\treturn bp, nil\n}\n\nfunc (b *BrowserType) connect(\n\tctx, vuCtx context.Context, wsURL string, opts *common.BrowserOptions, logger *log.Logger,\n) (*common.Browser, error) {\n\tbrowserProc, err := b.link(ctx, wsURL, logger)\n\tif browserProc == nil {\n\t\treturn nil, fmt.Errorf(\"connecting to browser: %w\", err)\n\t}\n\n\t// If this context is cancelled we'll initiate an extension wide\n\t// cancellation and shutdown.\n\tbrowserCtx, browserCtxCancel := context.WithCancel(vuCtx)\n\tb.Ctx = browserCtx\n\tbrowser, err := common.NewBrowser(\n\t\tctx, browserCtx, browserCtxCancel, browserProc, opts, logger,\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"connecting to browser: %w\", err)\n\t}\n\n\treturn browser, nil\n}\n\nfunc (b *BrowserType) link(\n\tctx context.Context,","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/chromium/browser_type.go#L192-L228","documentation":"BrowserType.link failed to establish the CDP WebSocket connection to the browser at wsURL, returning a nil browser process. The wrapped error carries the underlying dial/WebSocket handshake failure; later, Connect wraps it in a UserFriendlyError with timeout context.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/chromium/browser_type.go:210 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the browser/CDP endpoint is up and reachable (network, firewall, correct port)","Increase K6_BROWSER_TIMEOUT if the handshake is slow","For remote runs check K6_INSTANCE_WS_URL / cloud connectivity; retry after fixing the endpoint"],"exampleFix":null,"handlingStrategy":"retry","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"}