{"record":{"id":"4ba3450bdaca2a7e","repo":"facebook/react","slug":"516","errorCode":"516","errorMessage":"Attempted to call a temporary Client Reference from the server but it is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.","messagePattern":"Attempted to call a temporary Client Reference from the server but it is on the client\\. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-server/src/ReactFlightServerTemporaryReferences.js","lineNumber":100,"sourceCode":"      `Cannot access ${String(name)} on the server. ` +\n        'You cannot dot into a temporary client reference from a server component. ' +\n        'You can only pass the value through to the client.',\n    );\n  },\n  set: function () {\n    throw new Error(\n      'Cannot assign to a temporary client reference from a server module.',\n    );\n  },\n};\n\nexport function createTemporaryReference<T>(\n  temporaryReferences: TemporaryReferenceSet,\n  id: string,\n): TemporaryReference<T> {\n  const reference: TemporaryReference<any> = Object.defineProperties(\n    function () {\n      throw new Error(\n        `Attempted to call a temporary Client Reference from the server but it is on the client. ` +\n          `It's not possible to invoke a client function from the server, it can ` +\n          `only be rendered as a Component or passed to props of a Client Component.`,\n      );\n    } as any,\n    {\n      $$typeof: {value: TEMPORARY_REFERENCE_TAG},\n    },\n  );\n  const wrapper = new Proxy(reference, proxyHandlers);\n  registerTemporaryReference(temporaryReferences, wrapper, id);\n  return wrapper;\n}\n\nexport function registerTemporaryReference(\n  temporaryReferences: TemporaryReferenceSet,\n  object: TemporaryReference<any>,\n  id: string,","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server/src/ReactFlightServerTemporaryReferences.js#L82-L118","documentation":"The temporary-reference wrapper is itself a function so it can sit in component/function positions, but calling it on the server is rejected: the callable value lives on the client and cannot be invoked across the boundary. React throws with the explicit direction — render it as a Component or forward it to Client Component props, never call it from server code.","triggerScenarios":"A Server Action receives a client callback as an argument and invokes it (const cb = args[0]; cb()); passing a temp ref into a higher-order server utility that calls function-typed arguments generically.","commonSituations":"Porting callback-style APIs (done(err), onSuccess(...)) into server actions; libraries that call any function-typed parameter; continuing an async flow from the server by 'notifying' the client.","solutions":["Return data from the action and let the client continue the flow with the result.","Pass the callback through to a Client Component that invokes it in the browser.","Replace the callback contract with a returned value or a follow-up server action the client calls."],"exampleFix":"// before — server action\n'use server';\nexport async function run(cb) { const r = compute(); cb(r); }\n\n// after — return the result; the client continues\n'use server';\nexport async function run() { return compute(); }\n// client\nconst r = await run(); onDone(r);","handlingStrategy":"type-guard","validationCode":"export function assertNotClientCallable(v: unknown, tempRefs: WeakMap<object, string>) {\n  if (typeof v === 'function' && tempRefs.has(v)) {\n    throw new Error('refusing to invoke a client-held temporary reference from the server');\n  }\n}","typeGuard":"export function isTemporaryReference(v: unknown, store: WeakMap<object, string>): v is (...a: any[]) => any {\n  return store.has(v as object);\n}","tryCatchPattern":"try {\n  cb();\n} catch (e) {\n  if (String((e as Error)?.message).includes('temporary Client Reference')) {\n    return respondWith('callback cannot run on the server; returning action result instead');\n  }\n  throw e;\n}","preventionTips":["Design action contracts around returned values, not callbacks.","Identity-check function arguments against the temporaryReferences store before invoking anything.","Pass client callbacks through to Client Components rather than executing them server-side."],"tags":["temporary-references","server-actions","callbacks","server-components"],"backgroundTag":"rsc-temporary-references","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}