grafana/k6 · error
disposing element with ID
Error message
disposing element with ID %s: %w
What it means
Wrap of the CDP Runtime.releaseObject command in BaseJSHandle.Dispose: when a handle is disposed and its remote object has an ID, k6 asks the browser to free the remote object; this wrap reports the object ID whose release failed. Context-canceled errors are deliberately swallowed (iteration teardown), so this error surfaces for real failures such as the object already being gone after navigation or the session being closed for another reason.
Solutions
- Usually safe to ignore when it occurs during page navigation or teardown — the object is already released
- Avoid holding JSHandle/ElementHandle references across navigations
- Call dispose() before the page navigates away if explicit cleanup matters
- Update k6; newer builds tolerate already-released objects more gracefully
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/js_handle.go:114 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/aa381477f6566271.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/js_handle.go:114
// We do not want to return an error when the error is a closed
// context. The reason the context would be closed is due to the
// iteration ending and therefore the associated browser and its assets
// will be automatically deleted.
if errors.Is(err, context.Canceled) {
h.logger.Debugf("BaseJSHandle:Dispose", "%v", err)
return nil
}
// The following error indicates that the object we're trying to release
// cannot be found, which would mean that the object has already been
// removed/deleted. This can occur when a navigation occurs, usually when
// a page contains an iframe.
if strings.Contains(err.Error(), "Cannot find context with specified id") {
h.logger.Debugf("BaseJSHandle:Dispose", "%v", err)
return nil
}
return fmt.Errorf("disposing element with ID %s: %w", h.remoteObject.ObjectID, err)
}
// dispose sends a command to the browser to release the remote object.
func (h *BaseJSHandle) dispose() error {
if h.disposed {
return nil
}
h.disposed = true
if h.remoteObject.ObjectID == "" {
return nil
}
act := runtime.ReleaseObject(h.remoteObject.ObjectID)
if err := act.Do(cdp.WithExecutor(h.ctx, h.session)); err != nil {
return fmt.Errorf("disposing element with ID %s: %w",
h.remoteObject.ObjectID, err)
}
return nilView on GitHub (pinned to 01ffac6f24)