{"record":{"id":"58937563804bf222","repo":"grafana/k6","slug":"extracting-value-from-remote-object-with-id-s-w","errorCode":null,"errorMessage":"extracting value from remote object with ID %s: %w","messagePattern":"extracting value from remote object with ID (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/execution_context.go","lineNumber":238,"sourceCode":"\t\te.logger.Debugf(\"ExecutionContext:eval\", \"Unexpected DevTools server error: %v\", err)\n\t\treturn nil, err\n\t}\n\tif exceptionDetails != nil {\n\t\treturn nil, fmt.Errorf(\"%s\", parseExceptionDetails(exceptionDetails))\n\t}\n\tvar res any\n\tif remoteObject == nil {\n\t\te.logger.Debugf(\n\t\t\t\"ExecutionContext:eval\",\n\t\t\t\"sid:%s stid:%s fid:%s ectxid:%d furl:%q remoteObject is nil\",\n\t\t\te.sid, e.stid, e.fid, e.id, e.furl)\n\t\treturn res, nil\n\t}\n\n\tif opts.returnByValue {\n\t\tres, err = valueFromRemoteObject(apiCtx, remoteObject)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\n\t\t\t\t\"extracting value from remote object with ID %s: %w\",\n\t\t\t\tremoteObject.ObjectID, err)\n\t\t}\n\t} else if remoteObject.ObjectID != \"\" {\n\t\t// Note: we don't use the passed in apiCtx here as it could be tied to a timeout\n\t\tres = NewJSHandle(e.ctx, e.session, e, e.frame, remoteObject, e.logger)\n\t}\n\n\treturn res, nil\n}\n\n// Based on: https://github.com/microsoft/playwright/blob/master/src/server/injected/injectedScript.ts\n//\n//go:embed js/injected_script.js\nvar injectedScriptSource string\n\n//nolint:gochecknoglobals\nvar injectedScriptSourceWithSourceURL = `(() => {` + injectedScriptSource + `; return new InjectedScript();})()` +","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/execution_context.go#L220-L256","documentation":"After a returnByValue evaluation succeeds, k6 unwraps the remote object's value (valueFromRemoteObject). If that unwrap fails — the object carries a value that cannot be decoded, or the object was released between evaluation and extraction — this error reports the failing object ID. It is a lower-level decode failure, distinct from page exceptions (which arrive via exceptionDetails).","triggerScenarios":"Evaluating expressions that return values Chromium marks unserializable in ways the wrapper cannot decode; objects released/disposed during navigation races between evaluation and value extraction; returning very large or deeply nested structures by value.","commonSituations":"Returning BigInts or huge structures from evaluate; races where navigation invalidates the remote object before k6 reads it.","solutions":["Return plain, small, JSON-friendly values from evaluate","For large or complex results, use evaluateHandle and then jsonValue() instead of by-value returns","Retry once — release races are transient","If it persists with well-formed values, report it as a k6 browser module issue with a minimal reproducer"],"exampleFix":"// before\nconst cfg = await page.evaluate(() => window.__hugeConfigObject);\n\n// after\nconst h = await page.evaluateHandle(() => window.__hugeConfigObject);\nconst cfg = await h.jsonValue();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  v = await page.evaluate(fn);\n} catch (e) {\n  if (/extracting value from remote object/.test(e.message)) {\n    const h = await page.evaluateHandle(fn);\n    v = await h.jsonValue();\n  } else throw e;\n}","preventionTips":["Keep evaluate return values small and JSON-shaped","Use evaluateHandle + jsonValue for large or complex objects","Project page-internal objects to plain data before returning them"],"tags":["browser","evaluate","serialization","cdp"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}