grafana/k6 · error

%s

Error message

%s

What it means

Returned by ExecutionContext.eval when the page-side evaluation completed with ExceptionDetails — i.e. the evaluated JS threw. parseExceptionDetails renders the JS exception (message, stack) into the error text. The JS code itself failed at runtime; this is not a transport or timeout error.

Solutions

  1. Fix the JS exception reported in the error text (see message/stack)
  2. Guard against nulls/undefined in evaluated page functions
  3. Wrap risky page code in try/catch inside the evaluated function to control the message
Defensive patterns

Strategy: try-catch

When it happens

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

Appendix: source

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

	var (
		remoteObject     *runtime.RemoteObject
		exceptionDetails *runtime.ExceptionDetails
		err              error
	)
	if remoteObject, exceptionDetails, err = action.Do(cdp.WithExecutor(apiCtx, e.session)); err != nil {
		var cdpe *cdproto.Error
		if errors.As(err, &cdpe) && cdpe.Code == devToolsServerErrorCode {
			// By creating a new error instead of reusing it, we're removing the
			// chromium specific error code.
			return nil, errors.New(cdpe.Message)
		}

		e.logger.Debugf("ExecutionContext:eval", "Unexpected DevTools server error: %v", err)
		return nil, err
	}
	if exceptionDetails != nil {
		return nil, fmt.Errorf("%s", parseExceptionDetails(exceptionDetails))
	}
	var res any
	if remoteObject == nil {
		e.logger.Debugf(
			"ExecutionContext:eval",
			"sid:%s stid:%s fid:%s ectxid:%d furl:%q remoteObject is nil",
			e.sid, e.stid, e.fid, e.id, e.furl)
		return res, nil
	}

	if opts.returnByValue {
		res, err = valueFromRemoteObject(apiCtx, remoteObject)
		if err != nil {
			return nil, fmt.Errorf(
				"extracting value from remote object with ID %s: %w",
				remoteObject.ObjectID, err)
		}
	} else if remoteObject.ObjectID != "" {

View on GitHub (pinned to 01ffac6f24)