grafana/k6 · error

enabling page lifecycle events

Error message

enabling page lifecycle events: %w

What it means

During initIsolatedWorld, the Page.setLifecycleEventsEnabled(true) CDP call failed, so page lifecycle events cannot be received for this frame. The wrapped error is Chromium's; setup of the frame session aborts. (Despite the function name, the lifecycle-enable call lives in this init path.)

Solutions

  1. Inspect the wrapped CDP error
  2. Check browser logs for crashes or protocol errors
  3. Update k6 and Chromium versions and retry
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/frame_session.go:456 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/063039728b5fde10. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/frame_session.go:509

		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)
	}

	if _, ok := fs.isolatedWorlds[name]; ok {
		fs.logger.Debugf("NewFrameSession:initIsolatedWorld",
			"sid:%v tid:%v, not found: %q",
			fs.session.ID(), fs.targetID, name)

		return nil
	}
	fs.isolatedWorlds[name] = true

	var frames []*Frame
	if fs.isMainFrame() {
		frames = fs.manager.Frames()
	} else {
		frame, ok := fs.manager.getFrameByID(cdp.FrameID(fs.targetID))
		if ok {
			frames = []*Frame{frame}

View on GitHub (pinned to 3fcf5388d7)