grafana/k6 · error

execution context not found

Error message

execution context %q not found

What it means

Returned by Frame.adoptBackendNodeID when the requested execution world's context is absent from the frame's context map at adoption time. A navigation/teardown race: the backend node cannot be adopted into a context that does not exist.

Solutions

  1. Retry the adoption after the frame loads
  2. Wait for the relevant lifecycle event before adopting
  3. Avoid concurrent navigation during adoption
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/frame.go:2252 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/063a39b9d71a5749. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/frame.go:2260

	navOpts := &FrameWaitForNavigationOptions{
		URL:       urlPattern,
		Timeout:   opts.Timeout,
		WaitUntil: opts.WaitUntil,
	}
	_, err = f.WaitForNavigation(navOpts, rm)

	return err
}

func (f *Frame) adoptBackendNodeID(world executionWorld, id cdp.BackendNodeID) (*ElementHandle, error) {
	f.log.Debugf("Frame:adoptBackendNodeID", "fid:%s furl:%q world:%s id:%d", f.ID(), f.URL(), world, id)

	f.executionContextMu.RLock()
	defer f.executionContextMu.RUnlock()

	ec := f.executionContexts[world]
	if ec == nil {
		return nil, fmt.Errorf("execution context %q not found", world)
	}
	return ec.adoptBackendNodeID(id)
}

func (f *Frame) evaluate(
	apiCtx context.Context,
	world executionWorld,
	opts evalOptions, pageFunc string, args ...any,
) (any, error) {
	f.log.Debugf("Frame:evaluate", "fid:%s furl:%q world:%s opts:%s", f.ID(), f.URL(), world, opts)

	f.executionContextMu.RLock()
	defer f.executionContextMu.RUnlock()

	ec := f.executionContexts[world]
	if ec == nil {
		return nil, fmt.Errorf("execution context %q not found", world)
	}

View on GitHub (pinned to 3fcf5388d7)