grafana/k6 · error
got a nil page frame tree
Error message
got a nil page frame tree
What it means
Page.getFrameTree succeeded but returned a nil frame tree, which the code treats as invalid: without a frame tree, no Frame objects can be created for the page. A nil result is unexpected from a healthy session — an internal inconsistency guard.
Solutions
- Retry the test; nil frame trees can occur transiently during navigation races
- Update k6 / Chromium
- Report to grafana/k6 if consistently reproducible
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/frame_session.go:438 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/5d790d0dbf59e322.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/frame_session.go:491
"sid:%v tid:%v", fs.session.ID(), fs.targetID)
action := cdppage.Enable()
if err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {
return fmt.Errorf("enabling page domain: %w", err)
}
var frameTree *cdppage.FrameTree
var err error
// Recursively enumerate all existing frames in page to create initial in-memory structures
// used for access and manipulation from JS.
action2 := cdppage.GetFrameTree()
if frameTree, err = action2.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {
return fmt.Errorf("getting page frame tree: %w", err)
} else if frameTree == nil {
// This can happen with very short scripts when we might not have enough
// time to initialize properly.
return fmt.Errorf("got a nil page frame tree")
}
// Any new frame may have a child frame, not just mainframes.
fs.handleFrameTree(frameTree, fs.isMainFrame())
if fs.isMainFrame() {
fs.initRendererEvents()
}
return nil
}
func (fs *FrameSession) initIsolatedWorld(name string) error {
fs.logger.Debugf("NewFrameSession:initIsolatedWorld",
"sid:%v tid:%v", fs.session.ID(), fs.targetID)
action := cdppage.SetLifecycleEventsEnabled(true)
if err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {
return fmt.Errorf("enabling page lifecycle events: %w", err)View on GitHub (pinned to 3fcf5388d7)