TypeError: Cannot read properties of undefined (reading '_logger')
MinskLeo opened this issue · 2 comments
MinskLeo commented
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
@peintnermax if you have some time, can you have a look?
andreas-soroko commented
had a quite similar issue
sign-in-error TypeError: Cannot read properties of undefined (reading '_logger')
at signinRedirect (UserManager.ts:156:14)
and had used it as follows
// zitadel.ts
export const signIn = userManager.signinRedirect;
//auth.tsx
// ....
await signIn(args)
on the stack trace, I could see that the error was thrown in the oidc-client-ts lib - that's why I suspected the error to be my fault.
changing the assignment to
export const signIn = userManager.signinRedirect.bind(userManager);
fixed my issue - maybe this will help you too