UserManager() call makes Angular app unstable
See original GitHub issueAfter using the call
this.userManager = new UserManager(oidcConfig);
my angular application gets stuck in an unstable state. This is tested by running the testability.isStable code in the console
var x = getAllAngularRootElements().every((root) => { var isStable = getAngularTestability(root).isStable(); console.log(root, 'is stable', isStable); });
There has been a previous issue opened on the old oidc-client-js repo - url
This has been fixed on the angular-auth-oidc-client and was wondering if this could be looked into url
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
new UserManager() call makes Angular app unstable #1294
I've been trying to figure out why my Angular app was not returning a stable state and found out it was stuck in...
Read more >Oidc-client infinite loop when calling signinRedirect
The issue is that I'm stuck inside infinite loop. Angular keeps calling IdenityServer and refreshing login page. The api call to the server...
Read more >10 Things You Should Avoid in Your ASP.NET Core Controllers
This is not only tiresome and repetitive, but it makes the code really unreadable. Imagine having complex models that you constantly need to...
Read more >User Authentication and Identity with Angular, Asp.Net Core ...
I have a problem, in app.component I call a service which try to fetch data from server, when this method is fired, in...
Read more >Build Angular Apps with Authentication Leveraging Sitefinity
Learn how to set up authentication for an Angular app that consumes Sitefinity CMS OData services using Sitefinity's easy-to-use OData SDK.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
oidc-client-ts uses a few
setInterval
andsetTimeout
over the place.And stated from the Angular doc :
angular-auth-oidc-client suffered from the same problem and the fix you mentioned was actually quite simple as they now run their setInterval and setTimeout outside angular:
But this fix was possible only because this library is 100% Angular made.
oidc-client-ts
on the other side is 100% JS so there is no way it can fix that issue. Moreover this issue relates to Angular and so it should be fixed in your application.Solution 1
You could simply wait for Angular to become stable then do what you want. Also wait for Angular to properly start (ie. ngOnInit) as using the constructor might also be too early.
But the issue with that approach is that you will delay the authentication and depending on your use case that might not be as bullet proof as it should be regarding security.
Solution 2
Use
oidc-client-ts
prior to launch your Angular application (ie. in themain.ts
beforebootstrapModule
).Two advantages with this one:
Solution 3
I actually developed an Angular library around
oidc-client-ts
that might be of interest. The library is still in beta but the desktop part is stable and complete, only the mobile part remains. Also the documentation is under redaction but what’s actually there is enough for a start.We initialise the UserManager within the constructor so
constructor( ) {
Once this code is hit the isStable become false and only becomes true when this line of code is commented out.