Uploaded image for project: 'Keycloak'
  1. Keycloak
  2. KEYCLOAK-15158

Javascript adapter init() is throwing a promise error after upgrade to 11

    XMLWordPrintable

    Details

    • Sprint:
      Keycloak Sprint 45
    • Steps to Reproduce:
      Hide

      Execute this code and it will error out on the keycloak.init

      this.keycloak.init({onLoad: 'check-sso'})
        .success((authenticated) => {
          this.loggedIn = authenticated;
          this.user = authenticated ? this.keycloak.tokenParsed : null;
          if (this.user) {
            this.user = Object.assign({}, {id: this.user.sub}, this.user);
          }
          resolve(authenticated);
        })
        .error(() => {
          this.loggedIn = false;
          this.user = null;
          resolve(false);
        }); 
      Show
      Execute this code and it will error out on the keycloak.init this .keycloak.init({onLoad: 'check-sso' }) .success((authenticated) => { this .loggedIn = authenticated; this .user = authenticated ? this .keycloak.tokenParsed : null ; if ( this .user) { this .user = Object .assign({}, {id: this .user.sub}, this .user); } resolve(authenticated); }) .error(() => { this .loggedIn = false ; this .user = null ; resolve( false ); });
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      We receive this error: Error: Uncaught (in promise): TypeError: Method Promise.prototype.then called on incompatible receiver [object Promise]

      When our app is doing a keycloak.init() like this: keycloak.init({onLoad: ‘check-sso’})

      This code was working in the older version and just broke after upgrading to 11.

      Here are the 3 errors that log in the browser console: 

      An error occurred Error: Uncaught (in promise): TypeError: Method Promise.prototype.then called on incompatible receiver [object Promise]
      TypeError: Method Promise.prototype.then called on incompatible receiver [object Promise]
       at e.then (<anonymous>)
       at e.nrWrapper [as __zone_symbol__then] (<anonymous>:2:23884)
       at 5.830749f2b6865bc4f746.js:1
       at new e (5.830749f2b6865bc4f746.js:1)
       at e.H.e.then (5.830749f2b6865bc4f746.js:1)
       at Keycloak.kc.init (keycloak.js:365)
       at main.b840b402f833c8558666.js:1
       at new e (5.830749f2b6865bc4f746.js:1)
       at e.fetchLoginStatus (main.b840b402f833c8558666.js:1)
       at e.getToken (main.b840b402f833c8558666.js:1)
       at j (5.830749f2b6865bc4f746.js:1)
       at j (5.830749f2b6865bc4f746.js:1)
       at 5.830749f2b6865bc4f746.js:1
       at e.invokeTask (5.830749f2b6865bc4f746.js:1)
       at Object.onInvokeTask (main.b840b402f833c8558666.js:1)
       at e.invokeTask (5.830749f2b6865bc4f746.js:1)
       at t.runTask (5.830749f2b6865bc4f746.js:1)
       at g (5.830749f2b6865bc4f746.js:1)
       at nrWrapper (<anonymous>:2:23884)
      e.handleError @ main.b840b402f833c8558666.js:1
      next @ main.b840b402f833c8558666.js:1
      r @ main.b840b402f833c8558666.js:1
      n.__tryOrUnsub @ main.b840b402f833c8558666.js:1
      n.next @ main.b840b402f833c8558666.js:1
      n._next @ main.b840b402f833c8558666.js:1
      n.next @ main.b840b402f833c8558666.js:1
      n.next @ main.b840b402f833c8558666.js:1
      n.emit @ main.b840b402f833c8558666.js:1
      (anonymous) @ main.b840b402f833c8558666.js:1
      e.invoke @ 5.830749f2b6865bc4f746.js:1
      t.run @ 5.830749f2b6865bc4f746.js:1
      e.runOutsideAngular @ main.b840b402f833c8558666.js:1
      onHandleError @ main.b840b402f833c8558666.js:1
      e.handleError @ 5.830749f2b6865bc4f746.js:1
      t.runGuarded @ 5.830749f2b6865bc4f746.js:1
      e @ 5.830749f2b6865bc4f746.js:1
      Zone.__load_patch.n.microtaskDrainDone @ 5.830749f2b6865bc4f746.js:1
      g @ 5.830749f2b6865bc4f746.js:1
      nrWrapper @ VM59:2
      Promise.then (async)
      nrWrapper @ VM59:2
      v @ 5.830749f2b6865bc4f746.js:1
      e.scheduleTask @ 5.830749f2b6865bc4f746.js:1
      onScheduleTask @ 5.830749f2b6865bc4f746.js:1
      e.scheduleTask @ 5.830749f2b6865bc4f746.js:1
      t.scheduleTask @ 5.830749f2b6865bc4f746.js:1
      t.scheduleMicroTask @ 5.830749f2b6865bc4f746.js:1
      I @ 5.830749f2b6865bc4f746.js:1
      e.then @ 5.830749f2b6865bc4f746.js:1
      e.appInitializer @ main.b840b402f833c8558666.js:1
      e.runInitializers @ main.b840b402f833c8558666.js:1
      (anonymous) @ main.b840b402f833c8558666.js:1
      (anonymous) @ main.b840b402f833c8558666.js:1
      e.invoke @ 5.830749f2b6865bc4f746.js:1
      onInvoke @ main.b840b402f833c8558666.js:1
      e.invoke @ 5.830749f2b6865bc4f746.js:1
      t.run @ 5.830749f2b6865bc4f746.js:1
      e.run @ main.b840b402f833c8558666.js:1
      e.bootstrapModuleFactory @ main.b840b402f833c8558666.js:1
      OQ @ main.b840b402f833c8558666.js:1
      (anonymous) @ main.b840b402f833c8558666.js:1
      nrWrapper @ VM59:2
      Promise.then (async)
      nrWrapper @ VM59:2
      document.getElementById.onload @ main.b840b402f833c8558666.js:1
      load (async)
      po33 @ main.b840b402f833c8558666.js:1
      i @ runtime.f3f1068c8e6a61c57ed4.js:1
      0 @ main.b840b402f833c8558666.js:1
      i @ runtime.f3f1068c8e6a61c57ed4.js:1
      t @ runtime.f3f1068c8e6a61c57ed4.js:1
      r @ runtime.f3f1068c8e6a61c57ed4.js:1
      (anonymous) @ main.b840b402f833c8558666.js:1
      
      main.b840b402f833c8558666.js:1 An error occurred Error: Uncaught (in promise): [object Undefined]
       at j (5.830749f2b6865bc4f746.js:1)
       at Object.reject (5.830749f2b6865bc4f746.js:1)
       at Object.setError (keycloak.js:1192)
       at keycloak.js:372
       at e.invoke (5.830749f2b6865bc4f746.js:1)
       at Object.onInvoke (main.b840b402f833c8558666.js:1)
       at e.invoke (5.830749f2b6865bc4f746.js:1)
       at t.run (5.830749f2b6865bc4f746.js:1)
       at 5.830749f2b6865bc4f746.js:1
       at e.invokeTask (5.830749f2b6865bc4f746.js:1)
      e.handleError @ main.b840b402f833c8558666.js:1
      next @ main.b840b402f833c8558666.js:1
      r @ main.b840b402f833c8558666.js:1
      n.__tryOrUnsub @ main.b840b402f833c8558666.js:1
      n.next @ main.b840b402f833c8558666.js:1
      n._next @ main.b840b402f833c8558666.js:1
      n.next @ main.b840b402f833c8558666.js:1
      n.next @ main.b840b402f833c8558666.js:1
      n.emit @ main.b840b402f833c8558666.js:1
      (anonymous) @ main.b840b402f833c8558666.js:1
      e.invoke @ 5.830749f2b6865bc4f746.js:1
      t.run @ 5.830749f2b6865bc4f746.js:1
      e.runOutsideAngular @ main.b840b402f833c8558666.js:1
      onHandleError @ main.b840b402f833c8558666.js:1
      e.handleError @ 5.830749f2b6865bc4f746.js:1
      t.runGuarded @ 5.830749f2b6865bc4f746.js:1
      e @ 5.830749f2b6865bc4f746.js:1
      Zone.__load_patch.n.microtaskDrainDone @ 5.830749f2b6865bc4f746.js:1
      g @ 5.830749f2b6865bc4f746.js:1
      nrWrapper @ VM59:2
      Promise.then (async)
      nrWrapper @ VM59:2
      v @ 5.830749f2b6865bc4f746.js:1
      e.scheduleTask @ 5.830749f2b6865bc4f746.js:1
      onScheduleTask @ 5.830749f2b6865bc4f746.js:1
      e.scheduleTask @ 5.830749f2b6865bc4f746.js:1
      t.scheduleTask @ 5.830749f2b6865bc4f746.js:1
      t.scheduleMicroTask @ 5.830749f2b6865bc4f746.js:1
      I @ 5.830749f2b6865bc4f746.js:1
      e.then @ 5.830749f2b6865bc4f746.js:1
      e.appInitializer @ main.b840b402f833c8558666.js:1
      e.runInitializers @ main.b840b402f833c8558666.js:1
      (anonymous) @ main.b840b402f833c8558666.js:1
      (anonymous) @ main.b840b402f833c8558666.js:1
      e.invoke @ 5.830749f2b6865bc4f746.js:1
      onInvoke @ main.b840b402f833c8558666.js:1
      e.invoke @ 5.830749f2b6865bc4f746.js:1
      t.run @ 5.830749f2b6865bc4f746.js:1
      e.run @ main.b840b402f833c8558666.js:1
      e.bootstrapModuleFactory @ main.b840b402f833c8558666.js:1
      OQ @ main.b840b402f833c8558666.js:1
      (anonymous) @ main.b840b402f833c8558666.js:1
      nrWrapper @ VM59:2
      Promise.then (async)
      nrWrapper @ VM59:2
      document.getElementById.onload @ main.b840b402f833c8558666.js:1
      load (async)
      po33 @ main.b840b402f833c8558666.js:1
      i @ runtime.f3f1068c8e6a61c57ed4.js:1
      0 @ main.b840b402f833c8558666.js:1
      i @ runtime.f3f1068c8e6a61c57ed4.js:1
      t @ runtime.f3f1068c8e6a61c57ed4.js:1
      r @ runtime.f3f1068c8e6a61c57ed4.js:1
      (anonymous) @ main.b840b402f833c8558666.js:1
      main.b840b402f833c8558666.js:1
      

       

      An error occurred Error: Uncaught (in promise): TypeError: Method Promise.prototype.then called on incompatible receiver [object Promise]
      TypeError: Method Promise.prototype.then called on incompatible receiver [object Promise]
       at e.then (<anonymous>)
       at e.nrWrapper [as __zone_symbol__then] (<anonymous>:2:23884)
       at 5.830749f2b6865bc4f746.js:1
       at new e (5.830749f2b6865bc4f746.js:1)
       at e.H.e.then (5.830749f2b6865bc4f746.js:1)
       at e.KeycloakPromise.success (keycloak.js:92)
       at main.b840b402f833c8558666.js:1
       at new e (5.830749f2b6865bc4f746.js:1)
       at e.fetchLoginStatus (main.b840b402f833c8558666.js:1)
       at e.getToken (main.b840b402f833c8558666.js:1)
       at j (5.830749f2b6865bc4f746.js:1)
       at j (5.830749f2b6865bc4f746.js:1)
       at 5.830749f2b6865bc4f746.js:1
       at e.invokeTask (5.830749f2b6865bc4f746.js:1)
       at Object.onInvokeTask (main.b840b402f833c8558666.js:1)
       at e.invokeTask (5.830749f2b6865bc4f746.js:1)
       at t.runTask (5.830749f2b6865bc4f746.js:1)
       at g (5.830749f2b6865bc4f746.js:1)
       at nrWrapper (<anonymous>:2:23884)
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              vmuzikar Václav Muzikář
              Reporter:
              tanya_unangst Tanya Unangst (Inactive)
              Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: