mauriciovigolo / keycloak-angular

Easy Keycloak setup for Angular applications.
MIT License
730 stars 280 forks source link

updateToken Cannot assign to read only property 'tokenTimeoutHandle' of object '[object Object]' #576

Open ekrem-kocak opened 2 months ago

ekrem-kocak commented 2 months ago

"@angular/common": "~17.3.0", "keycloak-angular": "^15.3.0", "keycloak-js": "^24.0.5"

When I call the updateToken() function from either the instance or KeycloakService, I receive the following error:

interval(10000).subscribe(() => {
          if (instance.token) {
            this.keycloakService
              .updateToken(290)
              .then((r) => {
                console.log(r);
              })
              .catch((e) => {
                console.error(e);
              });
          }
        });

The error message is:

zone.js:1695

Uncaught TypeError: Cannot assign to read only property 'tokenTimeoutHandle' of object '[object Object]'
    at setToken (keycloak.mjs:987:34)
    at req.onreadystatechange [as __zone_symbol__ON_PROPERTYreadystatechange] (keycloak.mjs:674:33)
    at XMLHttpRequest.wrapFn (zone.js:758:39)
    at _ZoneDelegate.invokeTask (zone.js:403:31)
    at Zone.runTask (zone.js:174:47)
    at ZoneTask.invokeTask [as invoke] (zone.js:484:34)
    at invokeTask (zone.js:1645:18)
    at globalCallback (zone.js:1676:29)
    at XMLHttpRequest.globalZoneAwareCallback (zone.js:1709:16)

Could you please help me with this issue?

image

image

image

I believe the issue is that kc.tokenTimeoutHandle is read-only, so it cannot be set to null. As a result, it throws an error, and the function does not work.