angular/angular-cli · error · Error
Rendering failed with ${numErrors} worker errors.
Error message
Rendering failed with ${numErrors} worker errors. What it means
During Angular prerendering (SSG), @angular-devkit/build-angular's _renderUniversal counts errors reported by the rendering worker pool and throws this Error when numErrors > 0, aborting the prerender builder run. Each worker error is also logged via context.logger.error just before the throw.
Source
Thrown at packages/angular_devkit/build_angular/src/builders/prerender/index.ts:236
minifyCss: !!normalizedStylesOptimization.minify,
outputPath,
route: route[0] === '/' ? route : '/' + route,
serverBundlePath,
};
return worker.run(options);
}),
)) as RenderResult[];
let numErrors = 0;
for (const { errors, warnings } of results) {
spinner.stop();
errors?.forEach((e) => context.logger.error(e));
warnings?.forEach((e) => context.logger.warn(e));
spinner.start();
numErrors += errors?.length ?? 0;
}
if (numErrors > 0) {
throw Error(`Rendering failed with ${numErrors} worker errors.`);
}
} catch (error) {
spinner.fail(`Prerendering routes to ${outputPath} failed.`);
assertIsError(error);
return { success: false, error: error.message };
}
spinner.succeed(`Prerendering routes to ${outputPath} complete.`);
if (browserOptions.serviceWorker) {
spinner.start('Generating service worker...');
try {
await augmentAppWithServiceWorker(
projectRoot,
context.workspaceRoot,
outputPath,
browserOptions.baseHref || '/',
browserOptions.ngswConfigPath,View on GitHub (pinned to bb72145f9a)
Solutions
- Read the individual worker error lines logged above the failure to find the failing route(s) and fix the underlying SSR error.
- Guard browser-only APIs with isPlatformBrowser() checks in afterNextRender or platform checks.
- Make HTTP calls use absolute URLs (or an interceptor providing the origin) during SSR.
- Reproduce locally with `ng run <project>:prerender` and render the failing route in isolation.
- Temporarily exclude the problematic route (prerender routes config) to unblock the build while fixing.
Example fix
// before
constructor() {
localStorage.setItem('lastVisit', Date.now().toString()); // throws in prerender worker
}
// after
constructor() {
afterNextRender(() => localStorage.setItem('lastVisit', Date.now().toString()));
} Defensive patterns
Strategy: try-catch
Validate before calling
// run prerender in CI gate ng run my-app:prerender || (echo 'Fix logged worker errors above'; exit 1)
Try / catch
try {
await executePrerender();
} catch (err) {
if (!(err instanceof Error && err.message.startsWith('Rendering failed with'))) throw err;
// inspect the logged worker errors, fix SSR code, rerun
return { success: false, error: err.message };
} Prevention
- Guard all window/document/localStorage usage with isPlatformBrowser or afterNextRender.
- Use absolute URLs for HTTP calls during SSR.
- Test `ng run app:prerender` locally before CI.
- Keep route resolver code SSR-safe.
- Read the per-route worker error logs above the failure message.
When it happens
Trigger: One or more routes throw during server-side rendering in the worker processes — runtime errors in components, missing browser globals referenced at SSR time, failed HTTP/data calls inside route resolvers or constructors, or template/runtime errors only manifesting during prerender of specific routes.
Common situations: Code using window/document/localStorage without isPlatformBrowser guards; HTTP requests to relative URLs during prerender; routes with invalid parameters; a recently changed component throwing on the server only.
Related errors
- 'handleSSGRoute' was called for a route which rendering mode
- The 'getPrerenderParams' function defined for the '${stripLe
- Error(s) occurred while extracting routes:\n${errors.map((er
- Could not find any routes to prerender.
- The builder requires a target.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/c8c881de3e9f1d1d.
Report an issue: GitHub.