{"record":{"id":"179eb76582d7649b","repo":"facebook/react","slug":"server-actions-must-be-functions","errorCode":null,"errorMessage":"Server actions must be functions","messagePattern":"Server actions must be functions","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-server-dom-parcel/src/server/ReactFlightDOMServerBrowser.js","lineNumber":295,"sourceCode":"export function decodeAction<T>(body: FormData): Promise<() => T> | null {\n  return decodeActionImpl(body, serverManifest);\n}\n\nexport function decodeFormState<S>(\n  actionResult: S,\n  body: FormData,\n): Promise<ReactFormState<S, ServerReferenceId> | null> {\n  return decodeFormStateImpl(actionResult, body, serverManifest);\n}\n\nexport function loadServerAction<F: (...any[]) => any>(id: string): Promise<F> {\n  const reference = resolveServerReference<any>(serverManifest, id);\n  return Promise.resolve(reference)\n    .then(() => preloadModule(reference))\n    .then(() => {\n      const fn = requireModule(reference);\n      if (typeof fn !== 'function') {\n        throw new Error('Server actions must be functions');\n      }\n      return fn;\n    });\n}\n","sourceCodeStart":277,"sourceCodeEnd":300,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-parcel/src/server/ReactFlightDOMServerBrowser.js#L277-L300","documentation":"In the browser-build server writer for Parcel, an incoming action request goes through loadServerAction: resolve the id against the server manifest, preload the referenced bundles, then require the module and use the resolved binding as the action. The binding must be a function; a missing export name (undefined after a rename) or a non-function export (const, object, class) fails the typeof check and throws.","triggerScenarios":"A 'use server' module whose referenced export is not a function, or whose export name no longer exists because the manifest is stale after a rename — requireModule resolves the module but the named binding is undefined.","commonSituations":"Renaming an exported action without rebuilding the manifest; exporting constants or objects alongside actions in a 'use server' file; default-vs-named export confusion between builds.","solutions":["Make every export of a 'use server' file an async function","Rebuild the manifest/bundles after renaming exports so ids and export names match","Add a unit test that imports each 'use server' module and asserts typeof export === 'function' for every name the manifest references"],"exampleFix":"// before — manifest says 'saveNote' but the module exports something else\n'use server';\nexport async function persistNote(note) { /* renamed */ }\nexport const noteSchema = {type: 'object'}; // non-function export gets referenced by stale id\n\n// after — only async function exports, manifest rebuilt\n'use server';\nexport async function saveNote(note) { /* ... */ }","handlingStrategy":"validation","validationCode":"// dev/CI check: every export of a 'use server' module must be a function\nimport * as actions from './note-actions';\nfor (const [name, value] of Object.entries(actions)) {\n  if (typeof value !== 'function') {\n    throw new Error(`note-actions exports non-function '${name}'`);\n  }\n}","typeGuard":"export function isServerActionExport(mod, name) {\n  const value = mod[name];\n  return typeof value === 'function';\n}","tryCatchPattern":"try {\n  await loadServerAction(id);\n} catch (e) {\n  if (/Server actions must be functions/.test(e.message)) {\n    // stale manifest or non-function export — rebuild and verify the named export exists\n    return new Response('Action unavailable', {status: 500});\n  }\n  throw e;\n}","preventionTips":["Keep 'use server' files limited to async function exports","Rebuild manifests whenever action exports are renamed","Assert typeof export === 'function' for every manifest-referenced name in CI"],"tags":["react-server-components","server-actions","parcel","exports"],"backgroundTag":"server-action-export-not-function","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}