zitadel / zitadel-react

Authenticate your ZITADEL users within your react applications
8 stars 6 forks source link

TypeError: Cannot read properties of undefined (reading '_logger') #6

Open MinskLeo opened 5 months ago

MinskLeo commented 5 months ago

Description

Hi. I have this error when I'm trying to call zitadel.userManager.signinRedirectCallback.

Environment

NX monorepo with regular Vite React app + TypeScript.

Lib version:

"@zitadel/react": "^1.0.2",

How instance created:

const config: ZitadelConfig = {
  authority: 'https://zitadel.my-domain.dev',
  client_id: '261132704165220354@testproject',
  redirect_uri: 'http://localhost:4200/callback',
  post_logout_redirect_uri: 'http://localhost:4200',
};

Error:

index.tsx:15 Callback parsing error:  TypeError: Cannot read properties of undefined (reading '_logger')
    at signinRedirectCallback (@zitadel_react.js?v=2ca991b3:3410:26)
    at index.tsx:13:15
    at index.tsx:20:5
    at commitHookEffectListMount (react-dom_client.js?v=2ca991b3:16904:34)
    at commitPassiveMountOnFiber (react-dom_client.js?v=2ca991b3:18152:19)
    at commitPassiveMountEffects_complete (react-dom_client.js?v=2ca991b3:18125:17)
    at commitPassiveMountEffects_begin (react-dom_client.js?v=2ca991b3:18115:15)
    at commitPassiveMountEffects (react-dom_client.js?v=2ca991b3:18105:11)
    at flushPassiveEffectsImpl (react-dom_client.js?v=2ca991b3:19486:11)
    at flushPassiveEffects (react-dom_client.js?v=2ca991b3:19443:22)

Library source code chunk:

  async signinRedirectCallback(url = window.location.href) {
    // ----- On line below error -----
    const logger2 = this._logger.create("signinRedirectCallback");
   // -------------------------------

    const user = await this._signinEnd(url);
    if (user.profile && user.profile.sub) {
      logger2.info("success, signed in subject", user.profile.sub);
    } else {
      logger2.info("no subject");
    }
    return user;
  }

Maybe someone already found a way how to fix error? Or maybe I did something wrong. I can provide React app for reproduction later if needed.

muhlemmer commented 5 months ago

@peintnermax if you have some time, can you have a look?