Error during app initialization
aouicher opened this issue · 2 comments
aouicher commented
Error :
undefined on query.js getLogger().error(error); --> undefined
utils.js:324 Uncaught TypeError: Cannot read properties of undefined (reading 'status')
at Object.checkError (authProvider.js:120:29)
at useLogoutIfAccessDenied.ts:49:18
at onError (usePermissions.ts:57:17)
at notifyManager.js:62:18
at NotifyManager2.notifyFn (notifyManager.js:10:7)
at notifyManager.js:77:20
at Array.forEach (<anonymous>)
at notifyManager.js:76:17
at NotifyManager2.batchedUpdates$1 [as batchNotifyFn] (react-dom.development.js:26140:12)
at notifyManager.js:75:16
From some days, (i don't remember a package updated), there are some error when app start. So, auth doesn't work any more.
Some infos:
I try with the demo project and it's the same. My cognito user pool seems correct.
package.json:
"dependencies": {
"amazon-cognito-identity-js": "^6.3.1",
"ra-auth-cognito": "^1.0.2",
"react": "^18.2.0",
"react-admin": "^4.12.0",
"react-dom": "^18.2.0"
},
JakeStoeffler commented
It's because of this checkError function. The error argument is sometimes undefined, leading to the crash. I switched it to the following code in my project:
async checkError(error) {
// Careful, error is sometimes undefined.
if (error?.status === 401 || error?.status === 403) {
throw new Error('Unauthorized');
}
},
djhi commented
Thanks for the report. Can you open a PR?