-
Notifications
You must be signed in to change notification settings - Fork 694
ngOnDestroy crashes SSR apps #740
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
Comments
Thx for reporting! <3 On one hand I guess the change wouldn't hurt, but there are two things that would make me think twice about this change. First, if you we'd do this, I suppose all instances of Second, I'm not sure how useful it would be to have this service "not crash" with Server Side Rendering? The reason is that I'm not sure what meaningful thing the app could do auth-wise when doing server side rendering? Although I haven't done much SSR myself yet, I'd always expected you'd need to provide a stub-implementation for the OAuthService type as a whole (or more likely: your wrapper service) for meaningful and reliable Server Side functionality? Those two together makes me wonder if it's worth the change? |
hey jeroen, thanks for replying. The problem is that at some point the OAuthModule (which includes the OAuthService) will be destroyed and thus can't evade the Not certainly sure how the second part could work. However since there are SSR examples in the repo documentation (https://github.com/manfredsteyer/angular-oauth2-oidc/blob/master/docs-src/server-side-rendering.md) I feel like there is a SSR usage for the library. Best, |
An instance would only be destroyed if it was ever
Hmm, on one hand you're right. On the other hand, to my personal preference, lack of consistency in a class on how a dependency is used will make future changes much harder.
Interesting! I didn't know. The links and the blogposts there are 2 years old though, so I'd take them with a pinch of salt. |
hey jeroen,
to be honest I haven't heard or seen any examples of a mock-type injection in a server-side app (besides of injection tokens for browser-objects such as
totally agree on this one. it should not be a problem to replace all just want to mention that this part has only been broken 7 days ago due to merging this PR #666 . I'd happily use v8, but since we are using Angular 9 this seems not to be an option. |
I'm also having this issue not directly with SSR but with an app shell which uses a single SSR call on build time to render the shell route. It worked before but now it fails cause of this document call. I'm now trying to prevent OAuthService from loading at all by splitting server modules and client module, but it would be great if this can be addressed. |
Describe the bug
ngOnDestroy
kills SSR due to unchecked usage ofdocument
To Reproduce
destroy an instance of OAuthService on a SSR-app
Expected behavior
Server does not crash
document
must be replaced byDOCUMENT
of@angular/common
The text was updated successfully, but these errors were encountered: