{"record":{"id":"a4655e9ed83b23e1","repo":"facebook/react","slug":"server-functions-cannot-be-called-during-initial-r-a4655e","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-turbopack/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-turbopack/src/client/ReactFlightDOMClientNode.js#L27-L63","documentation":"The Node SSR client runtime passes noServerCall as callServer when creating server references: during server-side rendering there is no browser request to attach a server-function call to, so invoking a server function while the render pass runs throws and points you at server components for initial data.","triggerScenarios":"Invoking a server action during SSR on Node — in a component body during prerender, in module scope evaluated while rendering, or in a lifecycle path that runs server-side (constructor, render body).","commonSituations":"Shared components that call actions on import or first render; analytics/telemetry actions fired during SSR; code migrated from client-only rendering without render-phase guards.","solutions":["Move server-function calls into event handlers or useEffect","Provide initial data from a parent server component via props","Guard shared code so action calls only run after hydration in the browser"],"exampleFix":"// before\nexport default function Dashboard() {\n  refreshStats(); // fires during SSR render -> Error\n  return <Stats />;\n}\n\n// after\nexport default function Dashboard() {\n  useEffect(() => { refreshStats(); }, []);\n  return <Stats />;\n}","handlingStrategy":"validation","validationCode":"function useServerActionAfterHydration(action) {\n  const hydrated = useRef(false);\n  useEffect(() => { hydrated.current = true; }, []);\n  return useCallback((...args) => {\n    if (!hydrated.current) {\n      throw new Error('Do not call server functions during SSR render');\n    }\n    return action(...args);\n  }, [action]);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Move render-phase action calls into effects or event handlers","Get initial data from parent server components via props","Guard shared components so actions fire only after hydration"],"tags":["server-actions","turbopack","ssr","node","render-phase"],"backgroundTag":"server-action-during-render","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}