grafana/k6 · error
retrieving json value
Error message
retrieving json value: %w
What it means
Wrap of Runtime.callFunctionOn in BaseJSHandle.JSONValue: for handles backed by a remote object ID, k6 calls "function() { return this; }" with ReturnByValue and AwaitPromise to serialize the object to a JSON-friendly remote object. This wrap reports that the CDP call itself failed — the remote object was released, the execution context was destroyed by navigation, or an awaited promise rejected inside the page.
Solutions
- Re-acquire the handle and call jsonValue() again if navigation invalidated the context
- Ensure any promise-backed handle resolves rather than rejects before reading its JSON value
- Verify the handle was not disposed earlier in the script
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/js_handle.go:202 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/2118333ecfacca0c.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/js_handle.go:202
continue
}
props[r.Name] = NewJSHandle(h.ctx, h.session, h.execCtx, h.execCtx.Frame(), r.Value, h.logger)
}
return props, nil
}
// 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)