grafana/k6 · warning
selectHandle.dispose
Error message
selectHandle.dispose: %w
What it means
Final cleanup step of frame.selectOption: the JSHandle for the <select> element itself is disposed after all option values are read. This error means that dispose failed — the owning execution context or CDP session was destroyed before cleanup completed.
Solutions
- Expect and tolerate the cleanup failure when the select intentionally navigates: verify post-state instead
- Wait for load state after the change event, then retry once if needed
- Avoid calling page.close() concurrently with in-flight frame actions
- Keep k6 current to pick up context-lifecycle fixes
Example fix
// tolerant pattern
let ok = false;
try {
page.selectOption('#lang', 'en');
ok = true;
} catch (e) {
page.waitForLoadState('load');
ok = page.$eval('#lang', el => el.value) === 'en';
}
if (!ok) throw new Error('language not selected'); Defensive patterns
Strategy: try-catch
Try / catch
let applied = false;
try {
page.selectOption(sel, val);
applied = true;
} catch (e) {
applied = page.$eval(sel, el => el.value) === val; // re-check on cleanup failure
}
if (!applied) throw new Error('selectOption did not apply'); Prevention
- Sequence teardown after actions complete (avoid concurrent page.close)
- Verify selection state independently of the call's success
When it happens
Trigger: Navigation, context switch, or page/target close between the option reads and the final dispose of the select handle.
Common situations: Same race as the option-handle dispose: selecting triggers navigation or the test tears down the page while selectOption is finishing; under high VU count the browser target can be recycled mid-call.
Related errors
- optionHandle.dispose
- an error occurred communicating with k6 Cloud
- an error occurred communicating with the provisioning API
- " " attribute is only supported for roles: "`).join(", ")}
- " " does not support " " matcher
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/67cea23683c8baf1.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/frame.go:1756
// pack the selected <option> values inside <select> into a slice
optHandles, err := selectHandle.getProperties()
if err != nil {
return nil, fmt.Errorf("getProperties: %w", err)
}
vals := make([]string, 0, len(optHandles))
for _, oh := range optHandles {
val, err := oh.JSONValue()
if err != nil {
return nil, fmt.Errorf("reading value: %w", err)
}
vals = append(vals, val)
if err := oh.dispose(); err != nil {
return nil, fmt.Errorf("optionHandle.dispose: %w", err)
}
}
if err := selectHandle.dispose(); err != nil {
return nil, fmt.Errorf("selectHandle.dispose: %w", err)
}
return vals, nil
}
// SetContent replaces the entire HTML document content.
func (f *Frame) SetContent(html string, _ *FrameSetContentOptions) error {
f.log.Debugf("Frame:SetContent", "fid:%s furl:%q", f.ID(), f.URL())
// TODO(@inancgumus): Respect the FrameSetContentOptions before executing the action.
// A solution is similar to the logic in `WaitForLoadState`.
js := `(html) => {
window.stop();
document.open();
document.write(html);
document.close();
}`View on GitHub (pinned to 3fcf5388d7)