Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: unhandled exception error during prerender #29884

Closed
1 task
imaksp opened this issue Mar 19, 2025 · 3 comments · Fixed by #29903
Closed
1 task

build: unhandled exception error during prerender #29884

imaksp opened this issue Mar 19, 2025 · 3 comments · Fixed by #29903
Assignees

Comments

@imaksp
Copy link

imaksp commented Mar 19, 2025

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.

@imaksp
Copy link
Author

imaksp commented Mar 19, 2025

additional info: API url was starting with undefined instead of https://, due to one code error, it works correctly if api server fails to respond or returns an incorrect response

@alan-agius4
Copy link
Collaborator

Are you using withFetch?

@imaksp
Copy link
Author

imaksp commented Mar 19, 2025

yes this is the related code, it also uses tanstack query:

  countriesQuery = injectQuery(() => ({
    queryKey: ['countryList'],
    queryFn: () => {
      return lastValueFrom(this.#profileService.getCountryList());
    },
  }));

@alan-agius4 alan-agius4 self-assigned this Mar 20, 2025
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Mar 20, 2025
Prior to this change, request errors were not handled correctly.

Closes angular#29884
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Mar 20, 2025
Prior to this change, request errors were not handled correctly.

Closes angular#29884
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Mar 20, 2025
Prior to this change, request errors were not handled correctly.

Closes angular#29884
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Mar 20, 2025
Prior to this change, request errors were not handled correctly.

Closes angular#29884
alan-agius4 added a commit that referenced this issue Mar 20, 2025
Prior to this change, request errors were not handled correctly.

Closes #29884

(cherry picked from commit 156a14e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants