grafana/k6 · error

unexpected DOM error type %T

Error message

unexpected DOM error type %T

What it means

Returned by errorFromDOMError when the value it receives from the injected script error channel is neither a string nor an error (e.g. nil, a number, or an arbitrary object). It is a defensive default branch: the DOM error propagation contract was violated, and the value's Go type is reported since no message can be extracted.

Solutions

  1. Report as a k6 browser module bug with a reproducing script
  2. Check that the injected script bundle matches the k6 version
  3. Retry in case of a transient serialization anomaly in the CDP channel
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/element_handle.go:1869 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18). Data as JSON: /api/errors/67ef7adc55e0fad4. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/element_handle.go:1873

		return true, nil // Continue retrying after delay
	}
}

func errorFromDOMError(v any) error {
	var (
		err  error
		serr string
	)
	switch e := v.(type) {
	case string:
		serr = e
	case error:
		if e == nil {
			return errors.New("DOM error is nil")
		}
		err, serr = e, e.Error()
	default:
		return fmt.Errorf("unexpected DOM error type %T", v)
	}
	if _, ok := errors.AsType[*k6ext.UserFriendlyError](err); ok {
		return err
	}
	if strings.Contains(serr, "timed out") {
		return &k6ext.UserFriendlyError{
			Err: ErrTimedOut,
		}
	}
	if s := "error:expectednode:"; strings.HasPrefix(serr, s) {
		return fmt.Errorf("expected node but got %s", strings.TrimPrefix(serr, s))
	}

	if serr == "error:notconnected" {
		return ErrElementNotAttachedToDOM
	}

	if errors.Is(err, ErrElementNotVisible) {

View on GitHub (pinned to 3fcf5388d7)