{"record":{"id":"91fc5b037c65de3d","repo":"grafana/k6","slug":"removing-frames-recursively-detaching-frame-w","errorCode":null,"errorMessage":"removing frames recursively: detaching frame: %w","messagePattern":"removing frames recursively: detaching frame: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame_manager.go","lineNumber":457,"sourceCode":"\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (m *FrameManager) removeFramesRecursively(frame *Frame) error {\n\tfor _, child := range frame.ChildFrames() {\n\t\tm.logger.Debugf(\"FrameManager:removeFramesRecursively\",\n\t\t\t\"fmid:%d cfid:%v pfid:%v cfname:%s cfurl:%s\",\n\t\t\tm.ID(), child.ID(), frame.ID(), child.Name(), child.URL())\n\n\t\tif err := m.removeFramesRecursively(child); err != nil {\n\t\t\treturn fmt.Errorf(\"removing frames recursively: %w\", err)\n\t\t}\n\t}\n\n\tif err := frame.detach(); err != nil {\n\t\treturn fmt.Errorf(\"removing frames recursively: detaching frame: %w\", err)\n\t}\n\n\tm.framesMu.Lock()\n\tm.logger.Debugf(\"FrameManager:removeFramesRecursively:delParentFrame\",\n\t\t\"fmid:%d fid:%v fname:%s furl:%s\",\n\t\tm.ID(), frame.ID(), frame.Name(), frame.URL())\n\n\tdelete(m.frames, cdp.FrameID(frame.ID()))\n\tm.framesMu.Unlock()\n\n\treturn nil\n}\n\nfunc (m *FrameManager) requestFailed(req *Request, canceled bool) {\n\tm.logger.Debugf(\"FrameManager:requestFailed\", \"fmid:%d rurl:%s\", m.ID(), req.URL())\n\n\tframe := req.getFrame()\n\tif frame == nil {","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/frame_manager.go#L439-L475","documentation":"Returned by FrameManager.removeFramesRecursively when frame.detach() fails for the frame being removed (the last step after its children were processed). The wrap distinguishes the detach step; the wrapped error is the CDP/context cleanup failure, often because the target was already destroyed.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame_manager.go:457 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Usually benign when the page/target is already closing; retry the outer operation","Avoid closing pages concurrently with operations touching their frames","Report if it fails on a live, stable page"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}