{"record":{"id":"2118333ecfacca0c","repo":"grafana/k6","slug":"retrieving-json-value-w","errorCode":null,"errorMessage":"retrieving json value: %w","messagePattern":"retrieving json value: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/js_handle.go","lineNumber":202,"sourceCode":"\t\t\tcontinue\n\t\t}\n\t\tprops[r.Name] = NewJSHandle(h.ctx, h.session, h.execCtx, h.execCtx.Frame(), r.Value, h.logger)\n\t}\n\n\treturn props, nil\n}\n\n// JSONValue returns a JSON version of this JS handle.\nfunc (h *BaseJSHandle) JSONValue() (string, error) {\n\tremoteObject := h.remoteObject\n\tif remoteObject.ObjectID != \"\" {\n\t\tvar err error\n\t\taction := runtime.CallFunctionOn(\"function() { return this; }\").\n\t\t\tWithReturnByValue(true).\n\t\t\tWithAwaitPromise(true).\n\t\t\tWithObjectID(h.remoteObject.ObjectID)\n\t\tif remoteObject, _, err = action.Do(cdp.WithExecutor(h.ctx, h.session)); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"retrieving json value: %w\", err)\n\t\t}\n\t}\n\n\tres, err := parseConsoleRemoteObject(h.logger, remoteObject)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"extracting json value (remote object id: %v): %w\", remoteObject.ObjectID, err)\n\t}\n\n\treturn res, nil\n}\n\n// ObjectID returns the remote object ID.\nfunc (h *BaseJSHandle) ObjectID() runtime.RemoteObjectID {\n\treturn h.remoteObject.ObjectID\n}\n","sourceCodeStart":184,"sourceCodeEnd":218,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/js_handle.go#L184-L218","documentation":"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.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/js_handle.go:202 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}