-
Notifications
You must be signed in to change notification settings - Fork 26.1k
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
Vite dev server crashes when HttpClient receives non-200 code #58123
Comments
This is a known issue with zoneless, and it not limited to dev-servers. |
In prod env, server will crash too? Is there any catch error mechanism that can be applied to not stop dev/prod app, but respond with 500 code? |
Yes, in the production environment, the server will crash because zone.js is not intercepting and handling unhandled errors and rejections. Since the error is "unhandled," the request's lifecycle will continue in this scenario. For a potential workaround, please refer to angular/angular-cli#28405 |
Implement the `attachNodeGlobalErrorHandlers` function to handle 'unhandledRejection' and 'uncaughtException' events in Node.js. This function logs errors to the console, preventing unhandled errors from crashing the server. It is particularly useful for zoneless apps, ensuring error handling without relying on zones. Closes #28581
Implement the `attachNodeGlobalErrorHandlers` function to handle 'unhandledRejection' and 'uncaughtException' events in Node.js. This function logs errors to the console, preventing unhandled errors from crashing the server. It is particularly useful for zoneless apps, ensuring error handling without relying on zones. Closes #28581
Implement the `attachNodeGlobalErrorHandlers` function to handle 'unhandledRejection' and 'uncaughtException' events in Node.js. This function logs errors to the console, preventing unhandled errors from crashing the server. It is particularly useful for zoneless apps, ensuring error handling without relying on zones. Closes #28581
Implement the `attachNodeGlobalErrorHandlers` function to handle 'unhandledRejection' and 'uncaughtException' events in Node.js. This function logs errors to the console, preventing unhandled errors from crashing the server. It is particularly useful for zoneless apps, ensuring error handling without relying on zones. Closes #28581
Moving to the FW repo as following the convo in angular/angular-cli#28405 (comment) the FW should handle the errors. |
This is quite annoying... Catching all node errors globally seems not to be the right solution, as discussed in angular/angular-cli#28405 (comment). Is there no recommended approach on how to handle these errors? For now I am using a global interceptor that just returns EMPTY on error. This is still quite bad, since it leaves the app in an unexpected state that likely needs a page refresh to work again, but at least the server does not crash. export const httpErrorInterceptor: HttpInterceptorFn = (req, next) => {
const toast = inject(ToastService)
return next(req).pipe(
catchError((err) => {
console.error(err);
toast.show("HTTP Error: " + err.message)
return EMPTY;
}),
);
}; |
Returning EMPTY or catching error project-wide will break rxResource. It’s better to move all your GET requests to rxResource and remove your project-wide error interceptor |
That would work I guess, but refactoring all http requestrs to use rxResource would be quite a hassle. |
Implement the `attachNodeGlobalErrorHandlers` function to handle 'unhandledRejection' and 'uncaughtException' events in Node.js. This function logs errors to the console, preventing unhandled errors from crashing the server. It is particularly useful for zoneless apps, ensuring error handling without relying on zones. Closes angular/angular#58123
Implement the `attachNodeGlobalErrorHandlers` function to handle 'unhandledRejection' and 'uncaughtException' events in Node.js. This function logs errors to the console, preventing unhandled errors from crashing the server. It is particularly useful for zoneless apps, ensuring error handling without relying on zones. Closes angular/angular#58123
Implement the `attachNodeGlobalErrorHandlers` function to handle 'unhandledRejection' and 'uncaughtException' events in Node.js. This function logs errors to the console, preventing unhandled errors from crashing the server. It is particularly useful for zoneless apps, ensuring error handling without relying on zones. Closes angular/angular#58123
Implement the `attachNodeGlobalErrorHandlers` function to handle 'unhandledRejection' and 'uncaughtException' events in Node.js. This function logs errors to the console, preventing unhandled errors from crashing the server. It is particularly useful for zoneless apps, ensuring error handling without relying on zones. Closes angular/angular#58123
Implement the `attachNodeGlobalErrorHandlers` function to handle 'unhandledRejection' and 'uncaughtException' events in Node.js. This function logs errors to the console, preventing unhandled errors from crashing the server. It is particularly useful for zoneless apps, ensuring error handling without relying on zones. Closes angular/angular#58123
Command
serve
Is this a regression?
The previous version in which this bug was not present was
v17
Description
Basically, it's a duplicate of angular/angular-cli#26192
But now it's here again with v19, zoneless and outputMode: 'server'.
Is this behaviour expected and not-an-issue on new setup?
Minimal Reproduction
ng serve
Exception or Error
No response
Your Environment
HttpErrorResponse
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: