{"record":{"id":"b6ade87cb9d815ce","repo":"facebook/react","slug":"server-functions-cannot-be-called-during-initial-r-b6ade8","errorCode":null,"errorMessage":"Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead.","messagePattern":"Server Functions cannot be called during initial render\\. This would create a fetch waterfall\\. Try to use a Server Component to pass data to Client Components instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-server-dom-unbundled/src/client/ReactFlightDOMClientNode.js","lineNumber":45,"sourceCode":"  serverModuleMap: null | ServerManifest,\n};\n\nimport type {Readable} from 'stream';\n\nimport {\n  createResponse,\n  createStreamState,\n  getRoot,\n  reportGlobalError,\n  processStringChunk,\n  processBinaryChunk,\n  close,\n} from 'react-client/src/ReactFlightClient';\n\nexport * from './ReactFlightDOMClientEdge';\n\nfunction noServerCall() {\n  throw new Error(\n    'Server Functions cannot be called during initial render. ' +\n      'This would create a fetch waterfall. Try to use a Server Component ' +\n      'to pass data to Client Components instead.',\n  );\n}\n\ntype EncodeFormActionCallback = <A>(\n  id: any,\n  args: Promise<A>,\n) => ReactCustomFormAction;\n\nexport type Options = {\n  nonce?: string,\n  encodeFormAction?: EncodeFormActionCallback,\n  unstable_allowPartialStream?: boolean,\n  findSourceMapURL?: FindSourceMapURLCallback,\n  replayConsoleLogs?: boolean,\n  environmentName?: string,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-unbundled/src/client/ReactFlightDOMClientNode.js#L27-L63","documentation":"The unbundled Node SSR client configuration (ReactFlightDOMClientNode, which re-exports the edge config) wires createServerReference to a noServerCall stub. Any attempt to invoke a Server Function while the initial Flight render/stream is in progress on the Node SSR pass throws immediately, because such a call would require a nested server request (fetch waterfall) in the middle of producing the initial payload.","triggerScenarios":"Calling a server function during SSR of the Flight response in a Node unbundled setup — directly in a component body, in a getter that render touches, or via code that runs while createFromNodeStream is still resolving the tree.","commonSituations":"Custom RSC Node servers using react-server-dom-unbundled/client node-edge configs; components that call actions during render; refactors that moved a call from an event handler into the render path; middleware or wrapper components that eagerly invoke passed functions.","solutions":["Move the invocation to an event handler or effect — never the component body","Lift the data need into a Server Component and pass results as props","Audit wrappers/HOCs that call functions passed to them instead of forwarding them"],"exampleFix":"// before\nfunction Search({query}) {\n  const results = search(query); // server function called during render\n  return <Results results={results} />;\n}\n\n// after: trigger from an event handler\nfunction Search() {\n  const [results, setResults] = useState(null);\n  return (\n    <>\n      <button onClick={async () => setResults(await search(query))}>Go</button>\n      {results ? <Results results={results} /> : null}\n    </>\n  );\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const root = getRootFromCreate(createFromNodeStream(payload, {serverConsumerManifest}));\n  renderToPipeableStream(root);\n} catch (e) {\n  if (e.message.includes('cannot be called during initial render')) {\n    // deterministic misuse: surface with the component stack and fix the call site\n    throw new Error('Server Function called during Node SSR render: ' + e.stack);\n  }\n  throw e;\n}","preventionTips":["Never call actions in component bodies, class constructors, or module scope","Treat any function crossing the server->client boundary as data to pass, not to invoke","Use React strict dev warnings and review render-phase effects when porting to RSC"],"tags":["react-server-components","server-functions","node","ssr"],"backgroundTag":"server-function-called-during-render","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}