withastro/astro · warning

Internal Warning: route cache overwritten.

Error message

Internal Warning: route cache overwritten. (${key})

What it means

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.

Solutions

  1. Update Astro to the latest patch release in case the invariant breach is already fixed
  2. Audit integrations that invoke a second render/build pass and make them reuse one container and route cache
  3. If it reproduces with stock configuration, open an astro repo issue with the full build log and a minimal repro
Defensive patterns

Strategy: validation

Validate before calling

const existing = routeCache.get(route);
if (existing?.staticPaths) {
  // reuse the cached entry; do not call set() again
} else {
  routeCache.set(route, entry);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of withastro/astro@52e6c34790 (2026-08-18). Data as JSON: /api/errors/23fb5cce6eeb6654. Report an issue: GitHub.

Appendix: source

Thrown at packages/astro/src/core/render/route-cache.ts:126

	private runtimeMode: RuntimeMode;

	constructor(logger: AstroLogger, runtimeMode: RuntimeMode = 'production') {
		this.logger = logger;
		this.runtimeMode = runtimeMode;
	}

	/** Clear the cache. */
	clearAll() {
		this.cache = {};
	}

	set(route: RouteData, entry: RouteCacheEntry): void {
		const key = this.key(route);
		// NOTE: This shouldn't be called on an already-cached component.
		// Warn here so that an unexpected double-call of getStaticPaths()
		// isn't invisible and developer can track down the issue.
		if (this.runtimeMode === 'production' && this.cache[key]?.staticPaths) {
			this.logger.warn(null, `Internal Warning: route cache overwritten. (${key})`);
		}
		this.cache[key] = entry;
	}

	get(route: RouteData): RouteCacheEntry | undefined {
		return this.cache[this.key(route)];
	}

	key(route: RouteData) {
		return `${route.route}_${route.component}`;
	}
}

const routeCaches = createManifestMemo(
	(manifest) => new RouteCache(getLogger(manifest), getEnvironment(manifest).runtimeMode),
);

/**

View on GitHub (pinned to 52e6c34790)