{"record":{"id":"1253d74d3fe62b7d","repo":"grafana/k6","slug":"value-v-out-of-range-for-int32-type","errorCode":null,"errorMessage":"value %v out of range for int32 type","messagePattern":"value (.+?) out of range for int32 type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":763,"sourceCode":"\t\t\t(node, injected, selector) => {\n\t\t\t\treturn injected.count(selector, node);\n\t\t\t}\n\t\t`\n\teopts := evalOptions{\n\t\tforceCallable: true,\n\t\treturnByValue: true,\n\t}\n\tresult, err := h.evalWithScript(\n\t\tapiCtx,\n\t\teopts, fn, parsedSelector,\n\t)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tswitch r := result.(type) {\n\tcase float64:\n\t\tif r < float64(math.MinInt32) || r > float64(math.MaxInt32) {\n\t\t\treturn 0, fmt.Errorf(\"value %v out of range for int32 type\", r)\n\t\t}\n\t\treturn int(r), nil\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"unexpected value %v of type %T\", r, r)\n\t}\n}\n\n// findFrameNavigationIndex finds the index of the first internal:control=enter-frame directive\nfunc (h *ElementHandle) findFrameNavigationIndex(selector *Selector) int {\n\tfor i, part := range selector.Parts {\n\t\tif part.Name == \"internal:control\" && part.Body == \"enter-frame\" {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn -1\n}\n\n// splitSelectorAtFrame splits a selector at the frame navigation boundary","sourceCodeStart":745,"sourceCodeEnd":781,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L745-L781","documentation":"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.","triggerScenarios":"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.","commonSituations":"Essentially never on healthy stock builds; appears with version-skewed custom builds or as fallout of session/context races.","solutions":["Re-locate the element and re-run count","Upgrade k6 so injected script and Go module match","If reproducible, report with the page and selector — include the printed value"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const n = await handle.count(sel);\n} catch (e) {\n  if (String(e).includes('out of range')) {\n    // corrupted eval result; re-locate and retry once, then upgrade k6\n  } else { throw e; }\n}","preventionTips":["Treat this as an internal defect signal, not a data problem","Keep k6 binary and injected script in sync"],"tags":["browser","count","injected-script","internal-invariant"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}