grafana/k6 · error
disposing document element while getting owner frame
Error message
disposing document element while getting owner frame: %w
What it means
Failure while releasing the JSHandle of the document element during getOwnerFrame cleanup, after the owner frame ID was already resolved. It fires in the cleanup path — the meaningful result may still be available, and the error usually indicates the session/context died mid-operation.
Solutions
- Call contentFrame()/frame ownership APIs while the page is stable (not navigating)
- Drop references to handles before closing pages
- Treat as non-fatal when it occurs during teardown
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/page.go:740 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/e20b82b10c5a2407.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/page.go:742
// share context between each other due to CORS.
//
// Instead here we use the element's session to retrieve the description of
// itself, which works even when we're handling elements that are not in
// an iframe.
node, err := action.Do(cdp.WithExecutor(p.ctx, h.session))
if err != nil {
p.logger.Debugf("Page:getOwnerFrame:DescribeNode:return", "sid:%v err:%v", p.sessionID(), err)
return "", nil
}
if node == nil {
p.logger.Debugf("Page:getOwnerFrame:node:nil:return", "sid:%v err:%v", p.sessionID(), err)
return "", nil
}
frameID := node.FrameID
if err := documentElement.Dispose(); err != nil {
return "", fmt.Errorf("disposing document element while getting owner frame: %w", err)
}
return frameID, nil
}
// errPageClosing is returned when a frame-session attachment is rejected
// because the page has started closing.
var errPageClosing = errors.New("page is closing")
func (p *Page) attachFrameSession(fid cdp.FrameID, fs *FrameSession) error {
p.logger.Debugf("Page:attachFrameSession", "sid:%v fid=%v", p.session.ID(), fid)
if fs == nil {
return errors.New("internal error: FrameSession is nil")
}
// This prevents a TOCTOU race where Close() snapshots owned sessions
// and then a new session is inserted outside that snapshot.View on GitHub (pinned to 3fcf5388d7)