grafana/k6 · error

initializing browser type: %w

Error message

initializing browser type: %w

What it means

Error "initializing browser type: %w" thrown in grafana/k6.

Source

Thrown at internal/js/modules/k6/browser/chromium/browser_type.go:135

//
// The passed context must be the context the caller wants to control both the
// connection and the browser lifetime; when it is canceled (iteration ends),
// the connection is torn down.
func (b *BrowserType) ConnectOverCDP(ctx context.Context, wsEndpoint string) (*common.Browser, error) {
	// Validate wsEndpoint up front so an empty or malformed value
	// fails fast with a clear error, instead of a confusing lower-level
	// connection error.
	if err := validateWSEndpoint(wsEndpoint); err != nil {
		return nil, err
	}

	// Parse browser options from the environment (K6_BROWSER_TIMEOUT,
	// K6_BROWSER_DEBUG, the log category filter, ...) like Connect does. Pass a
	// fixed chromium type instead of scenario options: connectOverCDP works
	// without a browser scenario, and Parse requires the type to be set.
	ctx, browserOpts, logger, err := b.init(ctx, true, map[string]any{"type": "chromium"})
	if err != nil {
		return nil, fmt.Errorf("initializing browser type: %w", err)
	}

	bp, err := b.connect(ctx, ctx, wsEndpoint, browserOpts, logger)
	if err != nil {
		err = &k6ext.UserFriendlyError{
			Err:     err,
			Timeout: browserOpts.Timeout,
		}
		return nil, fmt.Errorf("%w", err)
	}

	return bp, nil
}

// validateWSEndpoint returns an error if wsEndpoint is not a usable CDP
// WebSocket URL, catching common mistakes (an empty value, a non-ws scheme,
// a missing host, etc.) before we attempt to connect.
func validateWSEndpoint(wsEndpoint string) error {

View on GitHub (pinned to 93accf6570)

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/chromium/browser_type.go:135 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/b2b9f5dddf912239. Report an issue: GitHub.