auth0-samples / auth0-angular-samples

Auth0 Integration Samples for Angular 2+ Applications
https://auth0.com/docs/quickstart/spa/angular2
MIT License
280 stars 456 forks source link

NPM start on Angular sample error #172

Closed jupav closed 5 years ago

jupav commented 5 years ago

On fresh download of the sample app and when following along with the tutorial with pre-made app, the app crashes and I get the following error:

Chrome browser error:

Error: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.
Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)
    at Function.assertZonePatched (zone-evergreen.js:52)
    at new NgZone (core.js:34012)
    at getNgZone (core.js:35043)
    at PlatformRef.bootstrapModuleFactory (core.js:34882)
    at core.js:34961
    at auth0-spa-js.production.js:1

I think this error is produced where the AuthService creates an observable of Auth0 instance with the following code:

auth.service.ts:

auth0Client$ = (from(
    createAuth0Client({
      domain: environment.auth0.domain,
      client_id: environment.auth0.clientId,
      redirect_uri: `${window.location.origin}/callback`
    })
  ) as Observable<Auth0Client>).pipe(
    shareReplay(1), // Every subscription receives the same shared value
    catchError(err => throwError(err))
  );
lbalmaceda commented 5 years ago

Seems there's already someone working on the fix https://github.com/auth0/auth0-spa-js/pull/180

luisrudge commented 5 years ago

Fixed and released in @auth0/auth0-spa-js@1.2.1