{"record":{"id":"088b2644b4be9bcd","repo":"withastro/astro","slug":"failed-to-get-static-paths-from-the-cloudflare-pre","errorCode":null,"errorMessage":"Failed to get static paths from the Cloudflare prerender server (${response.status}: ${response.statusText}).${details}","messagePattern":"Failed to get static paths from the Cloudflare prerender server \\((.+?): (.+?)\\)\\.(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/integrations/cloudflare/src/prerenderer.ts","lineNumber":240,"sourceCode":"\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Failed to start the Cloudflare prerender server. The preview server did not return a valid address. ' +\n\t\t\t\t\t\t'This is likely a bug in @astrojs/cloudflare. Please file an issue at https://github.com/withastro/astro/issues',\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\tasync getStaticPaths(): Promise<PathWithRoute[]> {\n\t\t\t// Call the workerd endpoint to get static paths\n\t\t\tconst response = await fetch(`${serverUrl}${STATIC_PATHS_ENDPOINT}`, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: { 'Content-Type': 'application/json' },\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst body = await response.text();\n\t\t\t\tconst details = body ? `\\n${body}` : '';\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to get static paths from the Cloudflare prerender server (${response.status}: ${response.statusText}).${details}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst data: StaticPathsResponse = await response.json();\n\n\t\t\t// Deserialize the routes\n\t\t\treturn data.paths.map(({ pathname, route, cacheKey }) => ({\n\t\t\t\tpathname,\n\t\t\t\troute: deserializeRouteData(route),\n\t\t\t\tcacheKey,\n\t\t\t}));\n\t\t},\n\n\t\tasync render(request, { routeData, collectMetadata }) {\n\t\t\tconst body: PrerenderRequest = {\n\t\t\t\turl: request.url,\n\t\t\t\trouteData: serializeRouteData(routeData, trailingSlash),","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/integrations/cloudflare/src/prerenderer.ts#L222-L258","documentation":"After booting the workerd prerender server, the Cloudflare adapter POSTs to an internal endpoint to retrieve the list of routes that should be statically generated. A non-OK response fails the build with this error, appending the workerd response body which carries the root cause. It means route enumeration inside the worker failed, not that any single page failed to render.","triggerScenarios":"`astro build` with @astrojs/cloudflare where the worker-side code that walks the route manifest and decides prerenderability throws — for example a broken route module evaluated during startup, an adapter/workers-runtime version mismatch, or malformed route metadata (custom 404 handling, redirects config).","commonSituations":"Upgrading the adapter or workers runtime and hitting an incompatibility; a route module with top-level code that only fails under workerd; experimental adapter options interacting badly with the routes endpoint.","solutions":["Read the body appended to the message — it is the stack trace from the workerd process.","Check for route files whose module-level code (imports, side effects) throws under workerd and fix or guard them.","Update @astrojs/cloudflare together with astro; pin wrangler/workerd to a known-good version if a runtime regression is suspected.","Report to https://github.com/withastro/astro/issues if the body shows an internal adapter stack trace."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await build({ root: './' });\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (msg.includes('Failed to get static paths')) {\n    // the message body contains the workerd stack trace — log it verbatim for triage\n    console.error(msg.slice(msg.indexOf('\\n')));\n    process.exitCode = 1;\n  } else throw e;\n}","preventionTips":["Keep route modules side-effect free or workerd-safe at module scope.","Pin adapter and workerd/wrangler to versions tested together in CI.","Exercise a full `astro build` in CI on every PR so route-manifest regressions surface before deploy."],"tags":["cloudflare","prerender","routes","build","workerd"],"backgroundTag":"prerender-request-failed","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}