{"record":{"id":"1a3c29348b50b2fb","repo":"withastro/astro","slug":"this-is-an-error-caused-by-astro-and-not-your-code","errorCode":null,"errorMessage":"This is an error caused by Astro and not your code. Please file an issue.","messagePattern":"This is an error caused by Astro and not your code\\. Please file an issue\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/render/route-cache.ts","lineNumber":36,"sourceCode":"\tmod: ComponentInstance | undefined;\n\troute: RouteData;\n\trouteCache: RouteCache;\n\tssr: boolean;\n\tbase: AstroConfig['base'];\n\ttrailingSlash: AstroConfig['trailingSlash'];\n}\n\nexport async function callGetStaticPaths({\n\tmod,\n\troute,\n\trouteCache,\n\tssr,\n\tbase,\n\ttrailingSlash,\n}: CallGetStaticPathsOptions): Promise<GetStaticPathsResultKeyed> {\n\tconst cached = routeCache.get(route);\n\tif (!mod) {\n\t\tthrow new Error('This is an error caused by Astro and not your code. Please file an issue.');\n\t}\n\t// After HMR, `mod` is a new object from a fresh import(). If the cached\n\t// entry was produced by a previous module instance, treat it as stale so\n\t// getStaticPaths() is re-called with the updated module.\n\tif (cached?.staticPaths && cached.mod === mod) {\n\t\treturn cached.staticPaths;\n\t}\n\n\tvalidateDynamicRouteModule(mod, { ssr, route });\n\n\t// No static paths in SSR mode or for internal routes. Return an empty RouteCacheEntry.\n\tif ((ssr && !route.prerender) || route.origin === 'internal') {\n\t\tconst entry: GetStaticPathsResultKeyed = Object.assign([], { keyed: new Map() });\n\t\t// Store `mod` alongside the entry so the fast-path above hits on\n\t\t// subsequent requests; otherwise `cached.mod === mod` is always false\n\t\t// in SSR and we re-enter this branch, triggering the \"route cache\n\t\t// overwritten\" warning on every request after the first.\n\t\trouteCache.set(route, { ...cached, mod, staticPaths: entry });","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/render/route-cache.ts#L18-L54","documentation":"An internal guard inside callGetStaticPaths(): the route module (mod) passed in was undefined. Astro needs the module to read getStaticPaths and other exports, so an undefined module is always an Astro-internal failure, not user code.","triggerScenarios":"The module loader returned undefined for a route (import failed silently, Vite HMR produced an empty module, adapter/integration passed no module); a corrupted node_modules or build cache.","commonSituations":"After a failed HMR in dev; interrupted build leaving stale cache; custom integration or adapter mis-wiring render calls; very rare edge cases around dynamic import resolution.","solutions":["Restart the dev server or clear the Vite cache (node_modules/.vite, .astro cache).","Re-run the build from clean (rm -rf dist .astro node_modules/.vite).","If reproducible, file an issue at https://astro.build/issues with the route and stack trace.","Verify no integration is intercepting module loading and returning undefined."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// internal — wrap in a guard and surface a clearer message\ntry {\n  await callGetStaticPaths({ mod, route, ... });\n} catch (e) {\n  if (e instanceof Error && /Astro and not your code/.test(e.message)) {\n    console.error('Route module failed to load for', route.component);\n  }\n  throw e;\n}","preventionTips":["Keep dev/build caches clean (clear node_modules/.vite and .astro).","Restart the dev server after large dependency changes.","If reproducible, report it — undefined mod is an Astro-internal defect."],"tags":["internal","getstaticpaths","build","hmr"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}