Keycloak-angular: Uncaught errors logged to the console when not logged in

Created on 20 Aug 2018  路  10Comments  路  Source: mauriciovigolo/keycloak-angular

Bug Report or Feature Request (mark with an x)

- [X] bug report 
- [ ] feature request

When the app loads and you are not logged in, 3 errors are logged to the console.
If onLoad: 'check-sso' is NOT included in keycloak options then the number of errors drops to only 1.
If you are already logged, in then no errors will be logged to the console.

Versions.

keycloak-angular: 2.0.2
angular: 5.2.2
keycloak: 4.1.0.Final

Repro steps.

Here's the config and code I used.

import { APP_INITIALIZER } from '@angular/core';
import { KeycloakService, KeycloakOptions } from 'keycloak-angular';

import { environment } from '@taas/environments/environment';

const options: KeycloakOptions = {
  config: {
    url: environment.service.auth,
    realm: environment.keycloak.realm,
    clientId: environment.keycloak.clientId
  },
  initOptions: {
    checkLoginIframe: true,
    onLoad: 'check-sso', // this causes 2 of the errors
  },
  bearerPrefix: 'Bearer',
};

export function initializer(keycloakService: KeycloakService): () => Promise<boolean> {
  return () => keycloakService.init(options)
    .then(() => {
      console.log('Security initialized');
      return true;
    })
    .catch(err => { // I tried adding this to see if it would catch the errors but it doesn't.
      console.error('Security not initialized:', err);  
      return false;
    });
}

export const keycloakInitializer =  {
  provide: APP_INITIALIZER,
  useFactory: initializer,
  multi: true,
  deps: [KeycloakService]
};

The log given by the failure.

These 3 errors are logged in the console.

ERROR Error: Uncaught (in promise): [object Undefined]
    at resolvePromise (zone.js:814)
    at resolvePromise (zone.js:771)
    at eval (zone.js:873)
    at ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:4751)
    at ZoneDelegate.invokeTask (zone.js:420)
    at Zone.runTask (zone.js:188)
    at drainMicroTaskQueue (zone.js:595)
    at ZoneTask.invokeTask [as invoke] (zone.js:500)
    at invokeTask (zone.js:1540)

core.js:1449 ERROR Error: Uncaught (in promise): [object Undefined]
    at resolvePromise (zone.js:814)
    at resolvePromise (zone.js:771)
    at eval (zone.js:873)
    at ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:4751)
    at ZoneDelegate.invokeTask (zone.js:420)
    at Zone.runTask (zone.js:188)
    at drainMicroTaskQueue (zone.js:595)
    at ZoneTask.invokeTask [as invoke] (zone.js:500)
    at invokeTask (zone.js:1540)

core.js:1449 ERROR Error: Uncaught (in promise): [object Undefined]
    at resolvePromise (zone.js:814)
    at Object.eval [as reject] (zone.js:724)
    at Object.setError (keycloak.js:998)
    at messageCallback (keycloak.js:1111)
    at ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:4751)
    at ZoneDelegate.invokeTask (zone.js:420)
    at Zone.runTask (zone.js:188)
    at ZoneTask.invokeTask [as invoke] (zone.js:496)
    at invokeTask (zone.js:1540)

Desired functionality.

Desired functionality is that the errors are not logged to the console or have some way of handling them.

Bug

Most helpful comment

I have this problem with these versions:
keycloak-angular: 4.0.0
angular: 6+

All 10 comments

Hi @GearoidSugrue, I just reproduced this error on keycloak-heroes. I will take a closer look on this issue.

Thanks for reporting!

Thanks for the quick response!

I also have the same problem

@GearoidSugrue and @mel1nn, I'm working on this issue.

On newer versions of Angular and keycloak-angular, the problem is not happening. Seems to be related to zone.js, however I'm still looking at it. If it is something related to keycloak-angular, I will release a bugfix on the next version 4.0.1. This is also the reason for the delay of 4.0.1, but I'm planning to release it in the middle of this week.

Thanks!

I have this problem with these versions:
keycloak-angular: 4.0.0
angular: 6+

I'm having this problem too with these versions:
keycloak-angular: 4.0.2
keycloak-js: 4.5.0
angular: 6.1.9
zone-js: 0.8.26

Same here:
keycloak-angular 2.0.3
Keycloak 4.3.0
Angular 5.2

Same with
angular 7.0.0
keycloak 4.0.2

This is a known issue in keycloak-js, where it isn't using native promises, and should be fixed in 4.6.0.Final. At least it is marked as fixed for that release.

This has been resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Codinger386 picture Codinger386  路  4Comments

pahlers picture pahlers  路  3Comments

ayoubnejm picture ayoubnejm  路  3Comments

samherrmann picture samherrmann  路  3Comments

osafi picture osafi  路  5Comments