amplify-js: Storage.put() throws 'No credentials' error only in release mode
I’m using aws cognito userpool (email, pw) inside react native app. Uploading image to public s3 bucket works on debug mode. But in the release mode it fails with following error.
ReactNativeJS: { '[WARN] 01:25.693 StorageClass - ensure credentials error': { [TypeError: undefined is not a function (evaluating 'e.getPromise()')] line: 422, column: 8928, sourceURL: 'index.android.bundle' } }
ReactNativeJS:No credentials'
Inside, node_modules/@aws-amplify/core/Credentials.js (line 253)
var credentials = new Facet_1.AWS.CognitoIdentityCredentials({
IdentityPoolId: identityPoolId,
Logins: logins
}, {
region: region
});
This gets expired ‘credentials’ only in release mode. This leads to no credentials error.
Environment
- “aws-amplify”: “^1.0.2”
- “aws-amplify-react-native”: “^1.0.2”
- “react”: “16.4.1”
- “react-native”: “0.56.0”
- Android device API 26 and emulator API 24
- after
./gradlew assembleRelease && ./gradlew installRelease(not afterreact-native run-android)
Can anyone reproduce this and give some insight?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 24 (9 by maintainers)
@makeitraina yeah, I made it work by using
credentials.get()instead ofcredential.getPromise(). Will send a pr to fix this in amplify side and also raise this issue to the aws-sdk team.@malithjkmt can you open the debug mode by putting
window.LOG_LEVEL='DEBUG'in your code?I could not figure out why
getPromisewas not set in the credentials object so I ended up updating thecredentials.jsfile directly.getPromiseis just a simple wrapper that promisifies thegetproperty function of credentials. Here is my patchedcredentials.js@malithjkmt @SirNeuman @develop-stuartohare @anuradhawick I replaced
node_modules/aws-sdk/lib/credentials.jswith the link I shared as a temporary work-around. Hopefully @powerful23 can find the root-cause and provide a proper update.