By default, all http errors from backend endpoints or runtime errors in your SSR app are ignored by the Angular Universal Express engine. ExpressJS always returns to a client a "success" response (with a http status 200
) with whatever HTML got eventually rendered, regardless any runtime errors.
Obviously http errors from backend endpoints may result in missing the crucial data to be displayed in final HTML output. Or a runtime error in a componentβs logic might cause rendering incorrectly a part of the page. Because Angular Universal Express ignores such errors, the malformed HTML result sent to the client may be eventually indexed by Google, harming your SEO.
The only exception are unsuccessful APP_INITIALIZER
hooks (returning a rejected Promise or errored RxJs stream), which really interrupt the rendering. Such an error from APP_INITIALIZER
is thrown up to the ExpressJS server. This by default causes sending to a client a raw errorβs stacktrace along with the http status 500
.
For more, see a minimal reproduction repo: https://github.com/Platonn/angular-universal-14-error-handling-default
Disclaimer: this article refers to Angular in version 14.2. The next versions may differ in behavior.
Top comments (0)