grafana/k6 · warning

value %v out of range for int32 type

Error message

value %v out of range for int32 type

What it means

ElementHandle.count() converts the numeric result of injected.count to int and rejects values outside int32 range. A real DOM node count can never approach 2^31, so this signals a corrupted/invalid eval result (e.g. Infinity) rather than an actual element count.

Source

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

			(node, injected, selector) => {
				return injected.count(selector, node);
			}
		`
	eopts := evalOptions{
		forceCallable: true,
		returnByValue: true,
	}
	result, err := h.evalWithScript(
		apiCtx,
		eopts, fn, parsedSelector,
	)
	if err != nil {
		return 0, err
	}
	switch r := result.(type) {
	case float64:
		if r < float64(math.MinInt32) || r > float64(math.MaxInt32) {
			return 0, fmt.Errorf("value %v out of range for int32 type", r)
		}
		return int(r), nil
	default:
		return 0, fmt.Errorf("unexpected value %v of type %T", r, r)
	}
}

// findFrameNavigationIndex finds the index of the first internal:control=enter-frame directive
func (h *ElementHandle) findFrameNavigationIndex(selector *Selector) int {
	for i, part := range selector.Parts {
		if part.Name == "internal:control" && part.Body == "enter-frame" {
			return i
		}
	}
	return -1
}

// splitSelectorAtFrame splits a selector at the frame navigation boundary

View on GitHub (pinned to 93accf6570)

Solutions

  1. Re-locate the element and re-run count
  2. Upgrade k6 so injected script and Go module match
  3. If reproducible, report with the page and selector — include the printed value
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const n = await handle.count(sel);
} catch (e) {
  if (String(e).includes('out of range')) {
    // corrupted eval result; re-locate and retry once, then upgrade k6
  } else { throw e; }
}

Prevention

When it happens

Trigger: handle.count(selector) — including the frame-crossing variant — when the injected script returns a non-finite or huge number, e.g. from a broken injected-script bundle or a destroyed execution context returning garbage.

Common situations: Essentially never on healthy stock builds; appears with version-skewed custom builds or as fallout of session/context races.

Related errors


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