{"record":{"id":"e2eaa3bb5badd4df","repo":"grafana/k6","slug":"reading-value-w","errorCode":null,"errorMessage":"reading value: %w","messagePattern":"reading value: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":1748,"sourceCode":"\tv, err := call(f.ctx, act, opts.Timeout)\n\tif err != nil {\n\t\treturn nil, errorFromDOMError(err)\n\t}\n\tselectHandle, ok := v.(jsHandle)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected select element type %T\", v)\n\t}\n\n\t// pack the selected <option> values inside <select> into a slice\n\toptHandles, err := selectHandle.getProperties()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getProperties: %w\", err)\n\t}\n\tvals := make([]string, 0, len(optHandles))\n\tfor _, oh := range optHandles {\n\t\tval, err := oh.JSONValue()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"reading value: %w\", err)\n\t\t}\n\t\tvals = append(vals, val)\n\t\tif err := oh.dispose(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"optionHandle.dispose: %w\", err)\n\t\t}\n\t}\n\tif err := selectHandle.dispose(); err != nil {\n\t\treturn nil, fmt.Errorf(\"selectHandle.dispose: %w\", err)\n\t}\n\n\treturn vals, nil\n}\n\n// SetContent replaces the entire HTML document content.\nfunc (f *Frame) SetContent(html string, _ *FrameSetContentOptions) error {\n\tf.log.Debugf(\"Frame:SetContent\", \"fid:%s furl:%q\", f.ID(), f.URL())\n\n\t// TODO(@inancgumus): Respect the FrameSetContentOptions before executing the action.","sourceCodeStart":1730,"sourceCodeEnd":1766,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L1730-L1766","documentation":"In frame.selectOption, each selected <option> handle's JSONValue() is called to serialize the option's value. This error means serialization of one option handle failed — the remote object could not be read because its context was destroyed or the handle became invalid.","triggerScenarios":"The DOM mutates between selection and value read (options removed by a re-render), the page navigates mid-loop, or the CDP session drops while the option handles are being serialized.","commonSituations":"Framework-driven selects (React/Vue) that re-render options right after the change event; SPAs that route on select change; slow environments where the context times out.","solutions":["Stabilize the component: avoid re-render storms on change, or select via keyboard/click steps","Retry the whole selectOption after the page settles","Verify the selection afterward with $eval instead of relying on the return array","Increase the action timeout option so the read completes before any re-render"],"exampleFix":"// verify independently of the return value\npage.selectOption('#size', 'L');\nconst chosen = page.$eval('#size', el => el.value);\nif (chosen !== 'L') { throw new Error(`select failed, got ${chosen}`); }","handlingStrategy":"try-catch","validationCode":"page.waitForSelector(`${sel} option`, { state: 'attached', timeout: 5000 }); // options populated","typeGuard":null,"tryCatchPattern":"let vals = null;\ntry {\n  vals = page.selectOption(sel, val);\n} catch (e) {\n  vals = [page.$eval(sel, el => el.value)]; // read value independently\n}\nif (!vals.includes(val)) throw new Error('selection not applied');","preventionTips":["Verify selections with $eval(el => el.value) rather than trusting the returned array","Avoid selects whose options re-render immediately on change in tests"],"tags":["k6","browser","select","serialization","cdp"],"backgroundTag":"execution-context-destroyed","analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}