Closed gillicarmon closed 11 months ago
Hello, @gillicarmon and thanks for creating this issue. If you recently made the update from v4.2.9 of Amplify to the most recent v5.3.8, can you see if taking the following steps resolves the issue:
node_modules
folder.package-lock.json
file (if you have one).npm install
to reinstall all dependencies. Hello, @gillicarmon and thanks for creating this issue. If you recently made the update from v4.2.9 of Amplify to the most recent v5.3.8, can you see if taking the following steps resolves the issue:
- Delete your
node_modules
folder.- Delete your
package-lock.json
file (if you have one).- Run
npm install
to reinstall all dependencies.- If the issue isn't resolved after that, can you try rolling back to Amplify v5.3.6 to see if the error persists?
Thank you for the quick response. After the first 3 steps, the error remained. After changing version to v5.3.6 I was able to import Auth, but now I'm getting the same error after calling Auth.currentSession();
After quick debugging, seems like the issue is in file node_modules/@aws-amplify/auth/lib-esm/Auth.js
, line 1430 (inside currentUserPoolUser , .then(function () { return __awaiter(_this, void 0, void 0, function () {
The error:
TypeError: Cannot read property '__extends' of undefined, js engine: hermes
TypeError: Cannot read property '__awaiter' of undefined
I have a similar issue after upgrading to React Native 0.72.3. I am using amazon-cognito-identity-js
directly not via aws-amplify
. I am also using NX 16. Upon calling authenticateUser
I get the error:
TypeError: Cannot read property '__extends' of undefined, js engine: hermes
It is thrown when attempting to call:
const awsCryptoHash = new Sha256();
That is called from the hash
function in AuthenticationHelper.js
.
@gillicarmon, thank you for the additional information and rolling back to verify!
@david-gettins, this is also very helpful to know it's happening when using the amazon-cognito-identity-js
by itself and not even importing Auth.
Would both of you mind trying an upgrade to v5.3.10 of Amplify (latest version)? We've implemented quite a few changes in the last few versions since v5.3.6. If this does not resolve the issues, then I'll have some further follow up questions on the Nx and React Native side... but trying to see if we can isolate these issues on the Amplify side first.
@cwomack I'll try that over the weekend and get back to you.
Having this exact same issue with importing Amplify.
"aws-amplify": "5.3.10",
"react-native": "0.72.4",
"nx": "16.5.2",
Wasn't an upgrade in my case but a fresh expo app with nx, to which I added aws-amplify@latest.
@gillicarmon, thank you for the additional information and rolling back to verify!
@david-gettins, this is also very helpful to know it's happening when using the
amazon-cognito-identity-js
by itself and not even importing Auth.Would both of you mind trying an upgrade to v5.3.10 of Amplify (latest version)? We've implemented quite a few changes in the last few versions since v5.3.6. If this does not resolve the issues, then I'll have some further follow up questions on the Nx and React Native side... but trying to see if we can isolate these issues on the Amplify side first.
I have updated to the latest amazon-cognito-identity-js@6.3.5
but still face the same issue.
same error here after nx/react-native upgrade:
"amazon-cognito-identity-js": "^5.2.14",
"aws-amplify": "^5.0.14",
"aws-amplify-react-native": "^7.0.2",
"nx": "16.7.4",
"react-native": "0.72.3",
also upgrading to recommended versions as described above did not resolve the issue for me:
"amazon-cognito-identity-js": "^6.3.5",
"aws-amplify": "^5.3.10",
"aws-amplify-react-native": "^7.0.6",
"nx": "16.7.4",
"react-native": "0.72.3",
Update:
It appears that theses errors are related to option unstable_enablePackageExports
in the metro config, which was introduced along with the nx/react-native preset lately.
According to the docs this option will cause Metro to read the exports from package.json
, while providing a fallback when this is not possible.
I'm not sure whether this is the cause or just a workaround, but setting option unstable_enablePackageExports
to false in metro.config.js
seems to resolve the errors in my case:
resolver: {
assetExts: assetExts.filter((ext) => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
unstable_enableSymlinks: true,
unstable_enablePackageExports: false,
},
@gillicarmon or @david-gettins, can you maybe confirm this?
@rudgal I'll give it a try and get back to you
In testing it locally, I don't think the issue is being created on the Amplify side. I didn't see any issue on the Nx repo yet with a quick scan, but it looks like Nx users are complaining about something similar on the Expo repo in this issue https://github.com/expo/sentry-expo/issues/363.
@rudgal, thanks for providing a workaround! Looking forward to seeing if it resolves the issue for @david-gettins as well.
This issue may be relevant as well: https://github.com/getsentry/sentry-react-native/issues/3152
Update: It appears that theses errors are related to option
unstable_enablePackageExports
in the metro config, which was introduced along with the nx/react-native preset lately.According to the docs this option will cause Metro to read the exports from
package.json
, while providing a fallback when this is not possible.I'm not sure whether this is the cause or just a workaround, but setting option
unstable_enablePackageExports
to false inmetro.config.js
seems to resolve the errors in my case:resolver: { assetExts: assetExts.filter((ext) => ext !== 'svg'), sourceExts: [...sourceExts, 'svg'], blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]), unstable_enableSymlinks: true, unstable_enablePackageExports: false, },
@gillicarmon or @david-gettins, can you maybe confirm this?
I can confirm that this worked for me.
Update: It appears that theses errors are related to option
unstable_enablePackageExports
in the metro config, which was introduced along with the nx/react-native preset lately.According to the docs this option will cause Metro to read the exports from
package.json
, while providing a fallback when this is not possible.I'm not sure whether this is the cause or just a workaround, but setting option
unstable_enablePackageExports
to false inmetro.config.js
seems to resolve the errors in my case:resolver: { assetExts: assetExts.filter((ext) => ext !== 'svg'), sourceExts: [...sourceExts, 'svg'], blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]), unstable_enableSymlinks: true, unstable_enablePackageExports: false, },
@gillicarmon or @david-gettins, can you maybe confirm this?
Worked, thanks!
@gillicarmon, thank you for confirming! I'll close this issue down for now then seeing as the problem isn't on the Amplify side.
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
Authentication
Amplify Categories
auth
Environment information
Describe the bug
After upgrading our NX project to NX 16 & React Native 0.72.3, I'm getting an error when importing Auth from amplify-aws
this is my import
At first, I couldn't import amplify as well (when we were on version
aws-amplify - 4.2.9
), After upgrading to the latestaws-amplify-5.3.8
, I'm able to import Storage & Amplify, but not Auth. After investigating, I found the issue is with__extends(AuthClass, _super);
line 10 onnode_modules/@aws-amplify/auth/lib-esm/Auth.js
. If I'm comparing it to Storage.js which works, I can see their extends are implemented differently.Expected behavior
Being able to import both Storage, Amplify and Auth.
Reproduction steps
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response