{"record":{"id":"170f056136d6511d","repo":"withastro/astro","slug":"astro-couldn-t-find-the-correct-page-to-render-pr","errorCode":null,"errorMessage":"Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error, please file an issue.","messagePattern":"Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage\\. This is an internal error, please file an issue\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/environment/dev-nonrunnable.ts","lineNumber":55,"sourceCode":"\t\t\t};\n\t\t}\n\t}\n\n\tif (route.type === 'redirect') {\n\t\treturn RedirectSinglePageBuiltModule;\n\t} else {\n\t\tif (manifest.pageMap) {\n\t\t\tconst importComponentInstance = manifest.pageMap.get(route.component);\n\t\t\tif (!importComponentInstance) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Unexpectedly unable to find a component instance for route ${route.route}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn await importComponentInstance();\n\t\t} else if (manifest.pageModule) {\n\t\t\treturn manifest.pageModule;\n\t\t}\n\t\tthrow new Error(\n\t\t\t\"Astro couldn't find the correct page to render, probably because it wasn't correctly mapped for SSR usage. This is an internal error, please file an issue.\",\n\t\t);\n\t}\n}\n\nasync function getComponentByRoute(\n\tmanifest: SSRManifest,\n\trouteData: RouteData,\n): Promise<ComponentInstance> {\n\ttry {\n\t\tconst module = await getModuleForRoute(manifest, routeData);\n\t\treturn module.page();\n\t} catch {\n\t\t// could not find, ignore\n\t}\n\n\tconst url = new URL(routeData.component, manifest.rootDir);\n\tconst module = await import(/* @vite-ignore */ url.toString());","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/core/environment/dev-nonrunnable.ts#L37-L73","documentation":"The last-resort branch in the dev fallback: the manifest has neither a `pageMap` entry for the route nor a `pageModule`, so Astro cannot map the route to any renderable module and throws this internal error asking you to file an issue. It indicates an incomplete SSR manifest in the dev environment, not a mistake in your pages.","triggerScenarios":"A custom or experimental RenderEnvironment whose manifest provides neither `pageMap` nor `pageModule`; dev-manifest corruption after large structural changes (many files moved at once) while the server keeps serving requests.","commonSituations":"Projects using custom environments that hand-build an SSRManifest; dev races during heavy refactors; bugs in dev-time route collection.","solutions":["Restart the dev server (and clear `.astro/`) to regenerate the manifest.","If you maintain a custom environment, make sure its manifest sets `pageMap` (route.component → import) or a `pageModule`.","Reduce to a minimal repro and file an Astro issue if it happens with stock configuration."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Custom environments: ensure the manifest you hand to the renderer is complete\nconst manifest = {\n  pageMap: new Map(routes.map((r) => [r.component, () => import(r.component)])),\n  // or: pageModule for single-entry setups\n};","typeGuard":"function isRenderableManifest(m: { pageMap?: Map<string, unknown>; pageModule?: unknown }): boolean {\n  return m.pageMap instanceof Map || m.pageModule !== undefined;\n}","tryCatchPattern":"try {\n  await getComponentByRoute(manifest, routeData);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"correct page to render\")) {\n    // recover by rebuilding the dev manifest rather than crashing the request\n    await triggerDevManifestRebuild();\n    return;\n  }\n  throw err;\n}","preventionTips":["When implementing custom RenderEnvironments, always populate `pageMap` or `pageModule` in the manifest.","Restart dev and clear `.astro/` after large structural refactors.","File internal errors with a minimal repro so the invariant can be fixed upstream."],"tags":["internal","dev-server","ssr","custom-environments"],"backgroundTag":"custom-environment-misconfiguration","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}