{"record":{"id":"9493ab6b5ba1af47","repo":"remix-run/react-router","slug":"prerender-data-received-a-response-status-st","errorCode":null,"errorMessage":"Prerender (data): Received a ${response.status} status code from `entry.server.tsx` while prerendering the `${metadata.path}` path.\\n${pathname}","messagePattern":"Prerender \\(data\\): Received a (.+?) status code from `entry\\.server\\.tsx` while prerendering the `(.+?)` path\\.\\\\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-router-dev/vite/plugin.ts","lineNumber":2554,"sourceCode":"\n        // When `ssr:false` is set, we always want a SPA HTML they can use\n        // to serve non-prerendered routes.  This file will only SSR the root\n        // route and can hydrate for any path.\n        if (!ctx.reactRouterConfig.ssr) {\n          requests.push(createSpaModeRequest(ctx.reactRouterConfig));\n        }\n\n        return requests;\n      },\n      async postProcess(request, response, metadata) {\n        invariant(metadata);\n\n        // Handle loader data responses\n        if (metadata.type === \"data\") {\n          let pathname = new URL(request.url).pathname;\n\n          if (response.status !== 200 && response.status !== 202) {\n            throw new Error(\n              `Prerender (data): Received a ${response.status} status code from ` +\n                `\\`entry.server.tsx\\` while prerendering the \\`${metadata.path}\\` ` +\n                `path.\\n${pathname}`,\n              { cause: response },\n            );\n          }\n\n          let data = await response.text();\n\n          return {\n            files: [\n              {\n                path: pathname,\n                contents: data,\n              },\n            ],\n            // After saving the .data file, request the HTML page.\n            // The data is passed along to be embedded in the response header.","sourceCodeStart":2536,"sourceCodeEnd":2572,"githubUrl":"https://github.com/remix-run/react-router/blob/1fd704a7dabcbe3ae09d7387b460e6acaba30ec1/packages/react-router-dev/vite/plugin.ts#L2536-L2572","documentation":"Thrown in `postProcess` when `metadata.type === \"data\"`. For `.data` requests (turbo-stream loader output) React Router requires HTTP 200 or 202; any other status from `entry.server.tsx` is treated as a build-time failure because the prerendered `.data` file would be invalid. The thrown error captures the offending `Response` as `cause` for downstream handlers.","triggerScenarios":"A loader throws or returns a 4xx/5xx during prerendering; a `loader` redirects (3xx) for a path declared in `prerender`; the route is a `prerender` entry but its loader depends on request data unavailable at build time; `entry.server.tsx` returns an error response for that path.","commonSituations":"Listing a dynamic route in `prerender` whose loader reads `request.url` query params and 404s when none are present; loaders that throw on missing env vars during CI builds; a parent loader failing cascades to the child `.data` file.","solutions":["Reproduce the path locally with `react-router build && react-router preview` and open the `.data` URL to see the actual status/body.","Make the loader deterministic at build time (fallback to defaults instead of throwing for missing request data).","Remove the failing path from the `prerender` array or `prerender` function's returned list.","Return explicit redirects via the prerender-aware `redirect()` so the post-processor can render a meta-refresh fallback instead of erroring."],"exampleFix":"// before: loader throws for prerendered path\nexport const loader = ({ request }) => {\n  throw new Response(\"Not found\", { status: 404 });\n};\n// after: provide build-time defaults\nexport const loader = ({ request }) => {\n  return json({ items: FALLBACK_ITEMS });\n};","handlingStrategy":"validation","validationCode":"// Skip prerender entries whose loaders cannot succeed\nconst isSafeToPrerender = (path: string, dynamicPaths: Set<string>) =>\n  !dynamicPaths.has(path);\nexport const prerender = async () =>\n  allPaths.filter(p => isSafeToPrerender(p, unsafe));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make loaders deterministic for prerendered paths (no thrown errors).","Filter `prerender` lists against actually-routable, data-available paths.","Use `redirect()` for moves so the post-processor can render meta-refresh fallbacks."],"tags":["prerender","ssr-false","loader","entry-server","build"],"backgroundTag":null,"analyzedSha":"1fd704a7dabcbe3ae09d7387b460e6acaba30ec1","analyzedAt":"2026-08-12T13:54:57.804Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}