grafana/k6 · error

removing child frames recursively

Error message

removing child frames recursively: %w

What it means

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.

Solutions

  1. Usually transient during rapid navigations; retry the high-level operation
  2. Check for browser/target closure racing navigation
  3. Report if persistent (frame-manager state corruption)
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/frame_manager.go:269 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/7264e7868d8fbd75. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/frame_manager.go:269

		// isn't a bug in chrome, and seems to be intended behavior. Instead
		// of worrying about the nil frame and causing the test to fail when
		// the frame is nil, we can instead return early. The frame will
		// be initialized when getFrameTree CDP request is made, which will
		// call onFrameAttached and onFrameNavigated.

		return nil
	}

	m.logger.Debugf("FrameManager:frameNavigated:removeFrames",
		"fmid:%d fid:%v pfid:%v docid:%s fname:%s furl:%s initial:%t",
		m.ID(), frameID, parentFrameID, documentID, name, url, initial)

	if frame != nil {
		m.framesMu.Unlock()
		for _, child := range frame.ChildFrames() {
			if err := m.removeFramesRecursively(child); err != nil {
				m.framesMu.Lock()
				return fmt.Errorf("removing child frames recursively: %w", err)
			}
		}
		m.framesMu.Lock()
	}

	var mainFrame *Frame
	if isMainFrame && frame == nil {
		m.logger.Debugf("FrameManager:frameNavigated:MainFrame:initialMainFrameNavigation",
			"fmid:%d fid:%v pfid:%v docid:%s fname:%s furl:%s initial:%t",
			m.ID(), frameID, parentFrameID, documentID, name, url, initial)

		// Initial main frame navigation.
		frame = NewFrame(m.ctx, m, nil, frameID, m.logger)
		mainFrame = frame
	} else if isMainFrame && frame.ID() != string(frameID) {
		m.logger.Debugf("FrameManager:frameNavigated:MainFrame:delete",
			"fmid:%d fid:%v pfid:%v docid:%s fname:%s furl:%s initial:%t oldfid:%v",
			m.ID(), frameID, parentFrameID, documentID, name, url, initial, frame.ID())

View on GitHub (pinned to 01ffac6f24)