{"record":{"id":"23fb5cce6eeb6654","repo":"withastro/astro","slug":"internal-warning-route-cache-overwritten-key","errorCode":null,"errorMessage":"Internal Warning: route cache overwritten. (${key})","messagePattern":"Internal Warning: route cache overwritten\\. \\((.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/core/render/route-cache.ts","lineNumber":126,"sourceCode":"\tprivate runtimeMode: RuntimeMode;\n\n\tconstructor(logger: AstroLogger, runtimeMode: RuntimeMode = 'production') {\n\t\tthis.logger = logger;\n\t\tthis.runtimeMode = runtimeMode;\n\t}\n\n\t/** Clear the cache. */\n\tclearAll() {\n\t\tthis.cache = {};\n\t}\n\n\tset(route: RouteData, entry: RouteCacheEntry): void {\n\t\tconst key = this.key(route);\n\t\t// NOTE: This shouldn't be called on an already-cached component.\n\t\t// Warn here so that an unexpected double-call of getStaticPaths()\n\t\t// isn't invisible and developer can track down the issue.\n\t\tif (this.runtimeMode === 'production' && this.cache[key]?.staticPaths) {\n\t\t\tthis.logger.warn(null, `Internal Warning: route cache overwritten. (${key})`);\n\t\t}\n\t\tthis.cache[key] = entry;\n\t}\n\n\tget(route: RouteData): RouteCacheEntry | undefined {\n\t\treturn this.cache[this.key(route)];\n\t}\n\n\tkey(route: RouteData) {\n\t\treturn `${route.route}_${route.component}`;\n\t}\n}\n\nconst routeCaches = createManifestMemo(\n\t(manifest) => new RouteCache(getLogger(manifest), getEnvironment(manifest).runtimeMode),\n);\n\n/**","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/core/render/route-cache.ts#L108-L144","documentation":"RouteCache stores each route's getStaticPaths() result keyed by route+component and expects set() to run once. In production runtime mode it warns before overwriting an entry that already has staticPaths, because that means getStaticPaths (or route initialization) executed twice — the 'Internal Warning' prefix signals this is an invariant breach, normally triggered by integrations or an Astro bug rather than page code.","triggerScenarios":"During a production build or SSR render, RouteCache.set() is called twice for the same route when the first entry already stored staticPaths — e.g. an integration spinning up a second render pipeline over the same manifest, or duplicated build state.","commonSituations":"Custom integrations that re-render routes or rebuild the app container; tooling that re-runs the render step over built output; rare Astro internal regressions across versions.","solutions":["Update Astro to the latest patch release in case the invariant breach is already fixed","Audit integrations that invoke a second render/build pass and make them reuse one container and route cache","If it reproduces with stock configuration, open an astro repo issue with the full build log and a minimal repro"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const existing = routeCache.get(route);\nif (existing?.staticPaths) {\n  // reuse the cached entry; do not call set() again\n} else {\n  routeCache.set(route, entry);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In integrations, reuse one container/manifest instead of re-rendering routes","Treat this warning as a build-hygiene signal and investigate the double pass","Keep Astro patched so fixed internal regressions disappear"],"tags":["internal","route-cache","getstaticpaths","build"],"backgroundTag":"duplicate-cache-write","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"}