{"record":{"id":"b2b9f5dddf912239","repo":"grafana/k6","slug":"initializing-browser-type-w","errorCode":null,"errorMessage":"initializing browser type: %w","messagePattern":"initializing browser type: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/chromium/browser_type.go","lineNumber":135,"sourceCode":"//\n// The passed context must be the context the caller wants to control both the\n// connection and the browser lifetime; when it is canceled (iteration ends),\n// the connection is torn down.\nfunc (b *BrowserType) ConnectOverCDP(ctx context.Context, wsEndpoint string) (*common.Browser, error) {\n\t// Validate wsEndpoint up front so an empty or malformed value\n\t// fails fast with a clear error, instead of a confusing lower-level\n\t// connection error.\n\tif err := validateWSEndpoint(wsEndpoint); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Parse browser options from the environment (K6_BROWSER_TIMEOUT,\n\t// K6_BROWSER_DEBUG, the log category filter, ...) like Connect does. Pass a\n\t// fixed chromium type instead of scenario options: connectOverCDP works\n\t// without a browser scenario, and Parse requires the type to be set.\n\tctx, browserOpts, logger, err := b.init(ctx, true, map[string]any{\"type\": \"chromium\"})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"initializing browser type: %w\", err)\n\t}\n\n\tbp, err := b.connect(ctx, ctx, 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\n// validateWSEndpoint returns an error if wsEndpoint is not a usable CDP\n// WebSocket URL, catching common mistakes (an empty value, a non-ws scheme,\n// a missing host, etc.) before we attempt to connect.\nfunc validateWSEndpoint(wsEndpoint string) error {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/chromium/browser_type.go#L117-L153","documentation":"BrowserType.init failed inside ConnectOverCDP while preparing the browser context (logger setup, options parsing, or category filter). This wrap aggregates any of those init-step failures before the WebSocket connection to the remote browser is attempted.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/chromium/browser_type.go:135 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the wrapped error to identify which init step failed","Fix the corresponding K6_BROWSER_* env var or scenario option","Retry once env configuration is corrected"],"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"}