{"record":{"id":"e20b82b10c5a2407","repo":"grafana/k6","slug":"disposing-document-element-while-getting-owner-fra","errorCode":null,"errorMessage":"disposing document element while getting owner frame: %w","messagePattern":"disposing document element while getting owner frame: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/page.go","lineNumber":742,"sourceCode":"\t// share context between each other due to CORS.\n\t//\n\t// Instead here we use the element's session to retrieve the description of\n\t// itself, which works even when we're handling elements that are not in\n\t// an iframe.\n\tnode, err := action.Do(cdp.WithExecutor(p.ctx, h.session))\n\tif err != nil {\n\t\tp.logger.Debugf(\"Page:getOwnerFrame:DescribeNode:return\", \"sid:%v err:%v\", p.sessionID(), err)\n\t\treturn \"\", nil\n\t}\n\n\tif node == nil {\n\t\tp.logger.Debugf(\"Page:getOwnerFrame:node:nil:return\", \"sid:%v err:%v\", p.sessionID(), err)\n\t\treturn \"\", nil\n\t}\n\n\tframeID := node.FrameID\n\tif err := documentElement.Dispose(); err != nil {\n\t\treturn \"\", fmt.Errorf(\"disposing document element while getting owner frame: %w\", err)\n\t}\n\n\treturn frameID, nil\n}\n\n// errPageClosing is returned when a frame-session attachment is rejected\n// because the page has started closing.\nvar errPageClosing = errors.New(\"page is closing\")\n\nfunc (p *Page) attachFrameSession(fid cdp.FrameID, fs *FrameSession) error {\n\tp.logger.Debugf(\"Page:attachFrameSession\", \"sid:%v fid=%v\", p.session.ID(), fid)\n\n\tif fs == nil {\n\t\treturn errors.New(\"internal error: FrameSession is nil\")\n\t}\n\n\t// This prevents a TOCTOU race where Close() snapshots owned sessions\n\t// and then a new session is inserted outside that snapshot.","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/page.go#L724-L760","documentation":"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.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/page.go:740 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}