{"record":{"id":"20bab157acc320e4","repo":"withastro/astro","slug":"unexpectedly-unable-to-find-a-component-instance-f-20bab1","errorCode":null,"errorMessage":"Unexpectedly unable to find a component instance for route ${route.route}","messagePattern":"Unexpectedly unable to find a component instance for route (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/environment/production.ts","lineNumber":48,"sourceCode":"\t}\n\tlet routeToProcess = route;\n\tif (routeIsRedirect(route)) {\n\t\tif (route.redirectRoute) {\n\t\t\t// This is a static redirect\n\t\t\trouteToProcess = route.redirectRoute;\n\t\t} else {\n\t\t\t// This is an external redirect, so we return a component stub\n\t\t\treturn RedirectSinglePageBuiltModule;\n\t\t}\n\t} else if (routeIsFallback(route)) {\n\t\t// This is an i18n fallback route\n\t\trouteToProcess = getFallbackRoute(route, manifest.routes);\n\t}\n\n\tif (manifest.pageMap) {\n\t\tconst importComponentInstance = manifest.pageMap.get(routeToProcess.component);\n\t\tif (!importComponentInstance) {\n\t\t\tthrow new Error(`Unexpectedly unable to find a component instance for route ${route.route}`);\n\t\t}\n\t\treturn await importComponentInstance();\n\t} else if (manifest.pageModule) {\n\t\treturn manifest.pageModule;\n\t}\n\tthrow new Error(\n\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);\n}\n\nasync function getComponentByRoute(\n\tmanifest: SSRManifest,\n\trouteData: RouteData,\n): Promise<ComponentInstance> {\n\tconst module = await getModuleForRoute(manifest, routeData);\n\treturn module.page();\n}\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/core/environment/production.ts#L30-L66","documentation":"The production RenderEnvironment resolves route modules from the built SSRManifest's `pageMap` (after resolving i18n fallback routes). If `route.component` has no entry, it throws this internal error: the running server bundle's manifest does not describe the route it was asked to render. This is a build/deploy desync, not a user code error.","triggerScenarios":"Partial or mixed deploys where routes and the server manifest come from different builds; a custom adapter that filters or rewrites routes without updating `pageMap`; mixing old `dist` artifacts with new ones (cached Docker layers, incremental upload).","commonSituations":"Incremental deploys uploading only changed files; CDN/object-store caches serving a stale manifest; custom adapters manipulating the route list; rolling back only half the output.","solutions":["Do a clean rebuild (`rm -rf dist && astro build`) and deploy the whole output as one atomic unit.","Verify the deployed manifest actually lists the failing route (inspect the SSR manifest in `dist`).","Update your adapter to the latest version — route filtering bugs land here.","If it reproduces with stock adapters, file an issue with the route and adapter versions."],"exampleFix":"# before — mixed artifacts on the server\n# dist/server manifest from build A, pages from build B\n\n# after — clean rebuild, deploy dist as one unit\nrm -rf dist && npm run build && npm run deploy","handlingStrategy":"validation","validationCode":"// Custom server/integration: verify the deployed manifest knows the route\nif (!manifest.pageMap?.has(route.component)) {\n  throw new Error(`Deploy mismatch: rebuild and redeploy to serve ${route.route}`);\n}\nconst mod = await getComponentByRoute(manifest, route);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deploy `dist` atomically — never mix artifacts from two builds.","Invalidate CDN/container caches for the manifest when rolling out.","Stamp builds with a version and log it at startup to detect mixed deploys early."],"tags":["internal","ssr","deploy","routing"],"backgroundTag":"stale-build-artifact","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}