-
Notifications
You must be signed in to change notification settings - Fork 11.9k
fix(@angular/build): preserve error stack traces during prerendering #32872
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -116,8 +116,12 @@ export async function prerenderPages( | |||||
| sourcemap, | ||||||
| outputMode, | ||||||
| ).catch((err) => { | ||||||
| assertIsError(err); | ||||||
|
|
||||||
| return { | ||||||
| errors: [`An error occurred while extracting routes.\n\n${err.message ?? err.stack ?? err}`], | ||||||
| errors: [ | ||||||
| `An error occurred while extracting routes.\n\n${err.stack ?? err.message ?? err.code ?? err}`, | ||||||
| ], | ||||||
| serializedRouteTree: [], | ||||||
| appShellRoute: undefined, | ||||||
| }; | ||||||
|
|
@@ -265,8 +269,9 @@ async function renderPages( | |||||
| } | ||||||
| }) | ||||||
| .catch((err) => { | ||||||
| assertIsError(err); | ||||||
| errors.push( | ||||||
| `An error occurred while prerendering route '${route}'.\n\n${err.message ?? err.stack ?? err.code ?? err}`, | ||||||
| `An error occurred while prerendering route '${route}'.\n\n${err.stack ?? err.message ?? err.code ?? err}`, | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using the logical OR operator (
Suggested change
|
||||||
| ); | ||||||
| void renderWorker.destroy(); | ||||||
| }); | ||||||
|
|
@@ -371,7 +376,7 @@ async function getAllRoutes( | |||||
|
|
||||||
| return { | ||||||
| errors: [ | ||||||
| `An error occurred while extracting routes.\n\n${err.message ?? err.stack ?? err.code ?? err}`, | ||||||
| `An error occurred while extracting routes.\n\n${err.stack ?? err.message ?? err.code ?? err}`, | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using the logical OR operator (
Suggested change
|
||||||
| ], | ||||||
| serializedRouteTree: [], | ||||||
| }; | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using the logical OR operator (
||) here instead of nullish coalescing (??). While??handlesnullandundefined, it doesn't handle empty strings. Properties likeerr.stackorerr.messagecan be empty strings, which would cause this expression to resolve to an empty string, hiding error details. Using||would be more robust as it treats empty strings as falsy and falls back to the next property, ensuring a more descriptive error is always displayed.