{"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/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/chromium/browser_type.go#L117-L153","documentation":"Error \"initializing browser type: %w\" thrown in grafana/k6.","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":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}