{"record":{"id":"7264e7868d8fbd75","repo":"grafana/k6","slug":"removing-child-frames-recursively-w","errorCode":null,"errorMessage":"removing child frames recursively: %w","messagePattern":"removing child frames recursively: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame_manager.go","lineNumber":269,"sourceCode":"\t\t// isn't a bug in chrome, and seems to be intended behavior. Instead\n\t\t// of worrying about the nil frame and causing the test to fail when\n\t\t// the frame is nil, we can instead return early. The frame will\n\t\t// be initialized when getFrameTree CDP request is made, which will\n\t\t// call onFrameAttached and onFrameNavigated.\n\n\t\treturn nil\n\t}\n\n\tm.logger.Debugf(\"FrameManager:frameNavigated:removeFrames\",\n\t\t\"fmid:%d fid:%v pfid:%v docid:%s fname:%s furl:%s initial:%t\",\n\t\tm.ID(), frameID, parentFrameID, documentID, name, url, initial)\n\n\tif frame != nil {\n\t\tm.framesMu.Unlock()\n\t\tfor _, child := range frame.ChildFrames() {\n\t\t\tif err := m.removeFramesRecursively(child); err != nil {\n\t\t\t\tm.framesMu.Lock()\n\t\t\t\treturn fmt.Errorf(\"removing child frames recursively: %w\", err)\n\t\t\t}\n\t\t}\n\t\tm.framesMu.Lock()\n\t}\n\n\tvar mainFrame *Frame\n\tif isMainFrame && frame == nil {\n\t\tm.logger.Debugf(\"FrameManager:frameNavigated:MainFrame:initialMainFrameNavigation\",\n\t\t\t\"fmid:%d fid:%v pfid:%v docid:%s fname:%s furl:%s initial:%t\",\n\t\t\tm.ID(), frameID, parentFrameID, documentID, name, url, initial)\n\n\t\t// Initial main frame navigation.\n\t\tframe = NewFrame(m.ctx, m, nil, frameID, m.logger)\n\t\tmainFrame = frame\n\t} else if isMainFrame && frame.ID() != string(frameID) {\n\t\tm.logger.Debugf(\"FrameManager:frameNavigated:MainFrame:delete\",\n\t\t\t\"fmid:%d fid:%v pfid:%v docid:%s fname:%s furl:%s initial:%t oldfid:%v\",\n\t\t\tm.ID(), frameID, parentFrameID, documentID, name, url, initial, frame.ID())","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/frame_manager.go#L251-L287","documentation":"Returned inside FrameManager.frameNavigated when removing the old subtree's child frames after a navigation changed the frame's document fails. The wrap marks the recursive-cleanup step; the underlying detach error carries the cause. Frame-tree bookkeeping during navigation.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame_manager.go:269 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Usually transient during rapid navigations; retry the high-level operation","Check for browser/target closure racing navigation","Report if persistent (frame-manager state corruption)"],"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"}