withastro/astro · critical · Error

Astro couldn't find the correct page to render, probably bec

Error message

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.

What it means

An internal error thrown when the SSR pipeline's manifest has neither a `pageMap` entry for the route's component nor a `pageModule`. This means the built SSR output is malformed — every manifest should have one or the other. The error explicitly says 'this is an internal error, please file an issue.'

Source

Thrown at packages/astro/src/core/app/pipeline.ts:119

				return RedirectSinglePageBuiltModule;
			}
		} else if (routeIsFallback(route)) {
			// This is an i18n fallback route
			routeToProcess = getFallbackRoute(route, this.manifest.routes);
		}

		if (this.manifest.pageMap) {
			const importComponentInstance = this.manifest.pageMap.get(routeToProcess.component);
			if (!importComponentInstance) {
				throw new Error(
					`Unexpectedly unable to find a component instance for route ${route.route}`,
				);
			}
			return await importComponentInstance();
		} else if (this.manifest.pageModule) {
			return this.manifest.pageModule;
		}
		throw new Error(
			"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.",
		);
	}

	async tryRewrite(payload: RewritePayload, request: Request): Promise<TryRewriteResult> {
		const { newUrl, pathname, routeData } = findRouteToRewrite({
			payload,
			request,
			routes: this.manifest?.routes.map((r) => r.routeData),
			trailingSlash: this.manifest.trailingSlash,
			buildFormat: this.manifest.buildFormat,
			base: this.manifest.base,
			outDir: this.manifest?.serverLike ? this.manifest.buildClientDir : this.manifest.outDir,
		});

		const componentInstance = await this.getComponentByRoute(routeData);
		return { newUrl, pathname, componentInstance, routeData };
	}

View on GitHub (pinned to d081033d5f)

Solutions

  1. Delete the `dist/` directory and rebuild (`astro build`).
  2. Ensure you are using a compatible adapter version for your Astro version.
  3. Check that your `astro.config.*` output is set to `server` or `hybrid` as appropriate.
  4. File an Astro issue with your `astro.config.*`, adapter, and Astro version if it persists.
Defensive patterns

Strategy: validation

Validate before calling

function validateManifest(manifest: any): string[] {
  const errors: string[] = [];
  for (const route of manifest?.routes ?? []) {
    if (!manifest.pageMap?.get(route.routeData.component) && !manifest.pageModule) {
      errors.push(`Route ${route.routeData.route} has no component mapping`);
    }
  }
  return errors;
}

Type guard

function hasValidPageMapping(manifest: any): boolean {
  return Boolean(manifest?.pageMap || manifest?.pageModule);
}

Prevention

When it happens

Trigger: `pipeline.getIntegrityMetadata` / `getComponent` is called for a route. The manifest has `pageMap` but it's falsy/empty, and `pageModule` is also falsy. The final `throw new Error(...)` fires after both branches are skipped.

Common situations: A corrupted or incomplete build output in `dist/`. An adapter that generates a custom manifest incorrectly omits both `pageMap` and `pageModule`. A build was interrupted and left partial output. An Astro internal bug in manifest generation for a specific project configuration.

Related errors


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