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

  1. Read the individual worker error lines logged above the failure to find the failing route(s) and fix the underlying SSR error.
  2. Guard browser-only APIs with isPlatformBrowser() checks in afterNextRender or platform checks.
  3. Make HTTP calls use absolute URLs (or an interceptor providing the origin) during SSR.
  4. Reproduce locally with `ng run <project>:prerender` and render the failing route in isolation.
  5. 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

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


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/c8c881de3e9f1d1d. Report an issue: GitHub.