Skip to content

build: unhandled exception error during prerender #29884

Closed
@imaksp

Description

@imaksp

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

if route fails to prerender due to invalid http url during prerender, it gives following error, so we cannot find route having the error.

An unhandled exception occurred: Cannot read properties of undefined (reading 'stack')

Minimal Reproduction

add route with RenderMode.Prerender in new app, & call api with invalid http url in that component.
(not adding app as bug is clear in existing code, see anything else section)

Exception or Error

An unhandled exception occurred: Cannot read properties of undefined (reading 'stack')
    at /Users/***/node_modules/@angular-devkit/build-angular/node_modules/@angular/build/src/utils/server-rendering/prerender.js:153:94

Your Environment

Angular CLI: 19.2.3
Node: 22.13.1
Package Manager: yarn 4.7.0
OS: darwin arm64

Angular: 19.2.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.3
@angular-devkit/build-angular   19.2.3
@angular-devkit/core            19.2.3
@angular-devkit/schematics      19.2.3
@angular/cli                    19.2.3
@angular/ssr                    19.2.3
@schematics/angular             19.2.3
rxjs                            7.8.2
typescript                      5.8.2
zone.js                         0.15.0

Anything else relevant?

See following code:

.catch((err) => {
errors.push(
`An error occurred while prerendering route '${route}'.\n\n${err.stack ?? err.message ?? err.code ?? err}`,
);

in this code if err obj is undefined it won't log exact error, & error is actually undefined in this case.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions