withastro/astro · error · Error

This is an error caused by Astro and not your code. Please f

Error message

This is an error caused by Astro and not your code. Please file an issue.

What it means

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.

Source

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

	mod: ComponentInstance | undefined;
	route: RouteData;
	routeCache: RouteCache;
	ssr: boolean;
	base: AstroConfig['base'];
	trailingSlash: AstroConfig['trailingSlash'];
}

export async function callGetStaticPaths({
	mod,
	route,
	routeCache,
	ssr,
	base,
	trailingSlash,
}: CallGetStaticPathsOptions): Promise<GetStaticPathsResultKeyed> {
	const cached = routeCache.get(route);
	if (!mod) {
		throw new Error('This is an error caused by Astro and not your code. Please file an issue.');
	}
	// After HMR, `mod` is a new object from a fresh import(). If the cached
	// entry was produced by a previous module instance, treat it as stale so
	// getStaticPaths() is re-called with the updated module.
	if (cached?.staticPaths && cached.mod === mod) {
		return cached.staticPaths;
	}

	validateDynamicRouteModule(mod, { ssr, route });

	// No static paths in SSR mode or for internal routes. Return an empty RouteCacheEntry.
	if ((ssr && !route.prerender) || route.origin === 'internal') {
		const entry: GetStaticPathsResultKeyed = Object.assign([], { keyed: new Map() });
		// Store `mod` alongside the entry so the fast-path above hits on
		// subsequent requests; otherwise `cached.mod === mod` is always false
		// in SSR and we re-enter this branch, triggering the "route cache
		// overwritten" warning on every request after the first.
		routeCache.set(route, { ...cached, mod, staticPaths: entry });

View on GitHub (pinned to d081033d5f)

Solutions

  1. Restart the dev server or clear the Vite cache (node_modules/.vite, .astro cache).
  2. Re-run the build from clean (rm -rf dist .astro node_modules/.vite).
  3. If reproducible, file an issue at https://astro.build/issues with the route and stack trace.
  4. Verify no integration is intercepting module loading and returning undefined.
Defensive patterns

Strategy: try-catch

Try / catch

// internal — wrap in a guard and surface a clearer message
try {
  await callGetStaticPaths({ mod, route, ... });
} catch (e) {
  if (e instanceof Error && /Astro and not your code/.test(e.message)) {
    console.error('Route module failed to load for', route.component);
  }
  throw e;
}

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of withastro/astro@d081033d5f (2026-08-12). Data as JSON: /api/errors/1a3c29348b50b2fb. Report an issue: GitHub.