{"record":{"id":"85901d80d6d21c65","repo":"facebook/react","slug":"535","errorCode":"535","errorMessage":"renderToHTML should not have emitted Server References. This is a bug in React.","messagePattern":"renderToHTML should not have emitted Server References\\. This is a bug in React\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-markup/src/ReactMarkupServer.js","lineNumber":74,"sourceCode":"  | symbol\n  | null\n  | void\n  | bigint\n  | $AsyncIterable<ReactMarkupNodeList, ReactMarkupNodeList, void>\n  | $AsyncIterator<ReactMarkupNodeList, ReactMarkupNodeList, void>\n  | Iterable<ReactMarkupNodeList>\n  | Iterator<ReactMarkupNodeList>\n  | Array<ReactMarkupNodeList>\n  | Promise<ReactMarkupNodeList>; // Thenable<ReactMarkupNodeList>\n\ntype MarkupOptions = {\n  identifierPrefix?: string,\n  signal?: AbortSignal,\n  onError?: (error: mixed, errorInfo: ErrorInfo) => ?string,\n};\n\nfunction noServerCallOrFormAction() {\n  throw new Error(\n    'renderToHTML should not have emitted Server References. This is a bug in React.',\n  );\n}\n\nexport function experimental_renderToHTML(\n  children: ReactMarkupNodeList,\n  options?: MarkupOptions,\n): Promise<string> {\n  return new Promise((resolve, reject) => {\n    const flightResponse = createFlightResponse(\n      null,\n      null,\n      null,\n      noServerCallOrFormAction,\n      noServerCallOrFormAction,\n      undefined,\n      undefined,\n      false,","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-markup/src/ReactMarkupServer.js#L56-L92","documentation":"experimental_renderToHTML round-trips its tree through an embedded Flight response built with noServerCallOrFormAction wired into the response's server-reference hooks. If the tree contains a Server Reference (a 'use server' function, a form action, or a serialized server closure), decoding that reference invokes the stub, which throws - by policy, renderToHTML output must be inert HTML with no callable references.","triggerScenarios":"Passing a server-reference value into experimental_renderToHTML: a function from a 'use server' module, action={serverAction} on a form or button, or a child component that internally renders server references.","commonSituations":"Reusing RSC/Flight trees in a static-markup pipeline; forms built with server actions rendered to static HTML; passing almost-serializable props where one value is a server function.","solutions":["Remove server references and form actions from the tree passed to renderToHTML; pass plain serializable data instead.","If you need server actions, render with a Flight/SSR API (renderToReadableStream plus Flight) rather than renderToHTML.","If the tree is provably reference-free and this still throws, capture the component stack and file a React issue - the message itself marks it as a React bug."],"exampleFix":"// before\nawait experimental_renderToHTML(\n  <form action={createOrder}>...</form>,\n); // createOrder is a 'use server' function\n\n// after\nawait experimental_renderToHTML(\n  <form method='post' action='/api/order'>...</form>,\n);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const html = await experimental_renderToHTML(tree, {\n    onError: (e) => {\n      console.error(e);\n      return '<!-- render error -->';\n    },\n  });\n} catch (e) {\n  if (/Server References/.test(e.message)) {\n    // fall back to a reference-free tree (plain data instead of server functions)\n    const html = await experimental_renderToHTML(sanitizeTree(tree));\n  } else {\n    throw e;\n  }\n}","preventionTips":["Keep 'use server' functions and form actions out of trees passed to renderToHTML.","Pass plain serializable data (ids, URLs) and let the client call APIs instead.","Add a review check that greps the static-markup tree's modules for server-reference imports."],"tags":["server-components","server-references","react-markup","form-actions"],"backgroundTag":"server-reference-in-static-render","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}