I am currently working on replacing the old auth0-js implementation of our application with your new auth0-spa-js library. Even though I got it to work somehow, I am always getting the following error on the console which is caught by my error handler:
TypeError: Cannot read property 'close' of undefined
at a (auth0-spa-js.production.js:1)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:17290)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:498)
at invokeTask (zone.js:1744)
at globalZoneAwareCallback (zone.js:1781)
Anyone know what I am doing wrong? It is a lot of transforming of Promises to Observables, maybe that is the cause of the error. And it is actually a bit hacky to always check if the client is already created, but I wanted to encapsulate as much auth0 code as possible into the service.
Sadly, no. I cannot figure out whether I am doing anything wrong or if there is a problem in the library. I am hoping that someone from Auth0 Support has a look at this thread. Otherwise I would probably have to open a github issue. But it’s actually comforting to know that I am not the only one with that problem
A question to clarify: Which part needs to use https or localhost? I am currently using an ASP.NET Core Backend running on http-localhost and the Angular Development server running on http-localhost. In the thread you refered to, localhost was explicitly stated as working.
I think I might have found the problem. Because of the observables and multiple subscriptions, there might have been concurrency issues or multiple instances of the Auth0Client. I got rid of the error by doing it this way:
Create the client as shared observable in a similar way like you proposed in your updated angular quickstart:
private auth0Client$ = (from(createAuth0Client(this.config))).pipe(
shareReplay(1), // Every subscription receives the same shared value
Hi @schmaga (and others on this thread!), I just wanted to let you know that we’ve updated the Angular QuickStart to be more consistent with RxJS patterns in Angular. It might give you some ideas on how to structure your code now that you’ve moved past the errors you were getting.