grafana/k6 · error

resolving DOM node

Error message

resolving DOM node: %w

What it means

Returned by ExecutionContext.adoptBackendNodeID when the CDP dom.ResolveNode call (adopting a backend node into this execution context) fails. Wraps the CDP error; common causes are the node no longer existing, cross-origin frame restrictions, or the context being destroyed by navigation.

Solutions

  1. Retry the adoption after navigation settles
  2. Ensure the element still exists in the DOM
  3. Check for cross-process iframe restrictions if adopting across frames
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/execution_context.go:105 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/38577938b60d8a2c. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/execution_context.go:105

// Adopts specified backend node into this execution context from another execution context.
func (e *ExecutionContext) adoptBackendNodeID(backendNodeID cdp.BackendNodeID) (*ElementHandle, error) {
	e.logger.Debugf(
		"ExecutionContext:adoptBackendNodeID",
		"sid:%s stid:%s fid:%s ectxid:%d furl:%q bnid:%d",
		e.sid, e.stid, e.fid, e.id, e.furl, backendNodeID)

	var (
		remoteObj *runtime.RemoteObject
		err       error
	)

	action := dom.ResolveNode().
		WithBackendNodeID(backendNodeID).
		WithExecutionContextID(e.id)

	if remoteObj, err = action.Do(cdp.WithExecutor(e.ctx, e.session)); err != nil {
		return nil, fmt.Errorf("resolving DOM node: %w", err)
	}

	// This can occur due to race conditions between trying to click on an element
	// and chrome moving on (e.g. navigating).
	if remoteObj == nil {
		return nil, fmt.Errorf(`the page may have navigated away or the element is
			now missing. It might happen when k6 and/or Chrome are overloaded. You
			might need to increase the compute resources`)
	}

	return NewJSHandle(e.ctx, e.session, e, e.frame, remoteObj, e.logger).AsElement(), nil
}

// Adopts the specified element handle into this execution context from another execution context.
func (e *ExecutionContext) adoptElementHandle(eh *ElementHandle) (*ElementHandle, error) {
	var (
		efid cdp.FrameID
		esid target.SessionID

View on GitHub (pinned to 01ffac6f24)