grafana/k6 · error

extracting json value

Error message

extracting json value (remote object id: %v): %w

What it means

Wrap of parseConsoleRemoteObject in BaseJSHandle.JSONValue: after the remote object is (optionally) fetched by value, it must be decoded from the CDP RemoteObject representation into a JSON string. This wrap fires when that decoding step fails — the remote object's type/shape is one the parser cannot convert (e.g., a symbol, function, or undefined value), with the remote object ID included for debugging.

Solutions

  1. Use jsonValue() only on handles wrapping serializable data (objects, arrays, primitives)
  2. For non-serializable values, evaluate a custom page function that returns a string representation instead
  3. Re-fetch the handle if the remote object may have been released
Defensive patterns

Strategy: try-catch

When it happens

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

Appendix: source

Thrown at internal/js/modules/k6/browser/common/js_handle.go:208

}

// JSONValue returns a JSON version of this JS handle.
func (h *BaseJSHandle) JSONValue() (string, error) {
	remoteObject := h.remoteObject
	if remoteObject.ObjectID != "" {
		var err error
		action := runtime.CallFunctionOn("function() { return this; }").
			WithReturnByValue(true).
			WithAwaitPromise(true).
			WithObjectID(h.remoteObject.ObjectID)
		if remoteObject, _, err = action.Do(cdp.WithExecutor(h.ctx, h.session)); err != nil {
			return "", fmt.Errorf("retrieving json value: %w", err)
		}
	}

	res, err := parseConsoleRemoteObject(h.logger, remoteObject)
	if err != nil {
		return "", fmt.Errorf("extracting json value (remote object id: %v): %w", remoteObject.ObjectID, err)
	}

	return res, nil
}

// ObjectID returns the remote object ID.
func (h *BaseJSHandle) ObjectID() runtime.RemoteObjectID {
	return h.remoteObject.ObjectID
}

View on GitHub (pinned to 01ffac6f24)