Describe the bug
Cannot use aws-amplify to login with latest react-native version due to t.getPromise error on release builds and cannot update aws-amplify library due to Amplify.configure not working!
To Reproduce
Steps to reproduce the behavior:
In a react-native application create config like follows:
const config = {
Auth: {
identityPoolId: 'XXX...',
region: 'XXX...',
userPoolId: 'XXX...',
userPoolWebClientId: 'XXX...',
mandatorySignIn: false,
},
}
export default config
Import into App.js and configure
Amplify.configure(awsConfig)
Auth userPool is null and cannot use Auth.
In latest react-native release, cannot login with the above on aws-amplify 1.0.0 due to t.getPromise error.
Expected behavior
Configure should be able to authenticate and userPool should be defined.
Smartphone (please complete the following information):
Additional context
I can configure Auth directly, but Cache not defined and not working. Works on aws-amplify 1.0.0 but have a t.getPromise error for all login on release build with that version.
NOTE: We user our own components, not aws-amplify-react-native.
Looks this this might be related to the changes here: https://github.com/aws-amplify/amplify-js/commit/ce3c510836a76a69dcd3a2e614ce085a7b28b76d#diff-bc12c34febbccc7c5bdf9ede4f4767eb
@strykerCrew Hi can you also update aws-amplify-react-native to the latest version 2.0.3? The no userpool error is mostly caused by duplicate aws-amplify package under your node_modules.
We don't use the aws-amplify-react-native components, we only user the Amplify, Auth, and Cache for our login/authentication as we have custom components/views. Upgrading shouldn't and doesn't matter (just tried).
@strykerCrew if you don't need that package, you should remove it from package json and reinstall again. The previous version of it have a dependency on aws-amplify which may cause the problem.
@powerful23 I removed it and did a clean and install of the node modules and have this in my dependancies:
...
"aws-amplify": "^1.1.3",
...
"react": "^16.5.2",
"react-native": "^0.57.0",
...
Also, getting this in my debugger (perhaps circular import issues?):

If I manually configure auth:
Auth.configure(awsConfig.Auth)
Amplify.register(AsyncStorageCache)
I can get my Auth login to work, but I cannot persist the session as the cache gets cleared on app restart and this breaks the auth flow that works on the older version with react-native less than 0.56.
@strykerCrew there should be no aws-sdk under node_modules/@aws-amplify/${category}/node_modules. And The Auth will cache the session automatically so you don't need to register any cache into Amplify. Please don't include aws-sdk dependency in your package.json
@powerful23 I have no aws-sdk in the my package.json otherwise I would have listed.
So, this dependency shouldn't be here? https://github.com/aws-amplify/amplify-js/blob/master/packages/analytics/package.json#L58
That seems to be the only place it is a dependency outside of the core package in my package.json.
I tried doing the following, per the docs in my App.js (before doing what I mentioned in the last comment):
...
import Amplify from 'aws-amplify'
import awsConfig from 'aws-config'
Amplify.configure(awsConfig)
and Auth has no user pool information aka not initialized when trying to use when I upgraded. This works on [email protected], but due to react-native upgrade I cannot use that version due to the getPromise issue.
I manually went in and deleted these and it didn't matter.
@strykerCrew it's Amplify.configure() right? The final thing we can check is to open the debug mode by putting window.LOG_LEVEL='DEBUG' in your code and to see if auth module is configured or not.
Amplify.configure(awsConfig) (typo above) returns the config dictionary, but the Auth class does not appear to be configured. I followed the docs per the manual configuration and it does not work on the latest version.
Is this related? https://github.com/aws-amplify/amplify-js/issues/1323
@strykerCrew I noticed your aws-amplify-react-native package is not the latest one. Can you try update it to ^2.0.3, reinstall your node_modules again?
@powerful23 I removed aws-amplify-react-native completely as we use our own components, per your suggestion. I had to downgrade to [email protected] and [email protected] as this is the only configuration that works for the Auth class using Amplify.configure(awsConfig). The Auth class gets defined here as per the manual setup according to the docs, however the Auth class is not defined when upgrading to latest aws-amplify and returns TypeError: Cannot read property 'identityPoolId' of undefined as it is not configured. I have read the docs multiple times and I am following the setup as per written for manual configurations without the Authenticator or without using withAuthenticator.
I have deleted the node modules completely multiple times and let npm do its thing when installing aws-amplify, which is my only aws dependency in my package.json.
This is a complete BLOCKER for us to upgrade to the latest libraries.
@strykerCrew sorry about that. I kinda forgot that suggestion(too many issues around). I will try it with only using aws-amplify. Maybe you can try only using Auth to configure like:
import {Auth} from 'aws-amplify';
Auth.configure({
identityPoolId: ....
....
});
@powerful23 as per another previous comment I did try that, but then I get a Cache not registered error.
@strykerCrew I tried to reproduce in my local environment with a blank react-native app. Here is my package.json:
{
"name": "myapp_rn",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"aws-amplify": "^1.1.4",
"react": "16.4.1",
"react-native": "0.56.0"
},
"devDependencies": {
"babel-jest": "23.4.0",
"babel-preset-react-native": "^5",
"jest": "23.4.1",
"react-test-renderer": "16.4.1"
},
"jest": {
"preset": "react-native"
}
}
and this is my App.js:
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Button} from 'react-native';
import Amplify, { Auth } from 'aws-amplify';
window.LOG_LEVEL = 'DEBUG';
Amplify.configure({
Auth: {
identityPoolId: 'xxxx',
mandatorySignIn: true,
region: 'us-east-1',
userPoolId: 'xxxx',
userPoolWebClientId: 'xxxx'
}
});
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
type Props = {};
class App2 extends Component<Props> {
constructor(props) {
super(props);
this.state = {
text: 'empty'
};
this.test = this.test.bind(this);
this.cleanText = this.cleanText.bind(this);
}
async test() {
console.log(Auth.configure());
this.setState({
text: ''+JSON.stringify(Auth.configure())
});
try {
// just for testing
const user = await Auth.signIn(username, password);
console.log(user);
} catch (e) {
console.log(e);
}
}
async cleanText() {
this.setState({text: 'empty'});
}
render() {
return (
<View style={styles.container}>
<Button
title='test api'
onPress={this.test}
/>
<Button
title='clean text'
onPress={this.cleanText}
/>
<Text>
{this.state.text}
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
export default App2;
Tested both in development mode and release mode and no error found by far. I doubt there maybe something related to [email protected] but I couldn't build a blank app with that version I don't know why.
@powerful23 Ok, so you cannot create the same environment to try reproduce as I was using react-native 0.57? If you can get it working under that version, that would be great.
@powerful23 any updates on this?
@powerful23 or @jordanranz any updates?
@strykerCrew Hi we tested in React Native 0.57.0 and it worked with the latest version of Amplify under debug mode. Can you confirm that it's not working only in the release mode with the latest version of aws-amplify and aws-amplify-react-native? We will also try to test it in the release mode.
Please see thread, we do not use aws-amplify-react-native. We use our own components.
@strykerCrew hi I tested with [email protected] and [email protected] in the release mode yesterday. I tried sign in, sign out, sending events to pinpoint service and all worked for me.
@powerful23 I cannot verify this works due to https://github.com/aws-amplify/amplify-js/issues/2214
This looks to be resolved with at least the latest version.
I still got error "No userPool" after upgrade to latest version
react-native: 0.57.7
aws-amplify: 1.1.13
I'm also getting this No userPool error for gatsby build.
Works perfectly on dev environment but starts sending the error on serve (for both local and S3 hosted site)
Amplify.configure is manually set up on _App.js_
package.json
"aws-amplify" : "^1.1.10"
"gatsby" : "^2.0.55"
"react" : "^16.6.3"
+1 seeing this issue on 1.1.13 using angular.
any update? I still have the same problem at 1.1.26 with react
No userPool can be caused by a variety of things, so it is a case-by-case issue. That being said, I am going to close this issue because it seems the original poster's issue was solved. Please open a new issue with the necessary details so we can help reproduce and fix the problem.
there should be no
aws-sdkundernode_modules/@aws-amplify/${category}/node_modules
@powerful23 What if I need to execute AWS.config.credentials.clearCachedId() and make linked logins with AWS.CognitoIdentityCredentials? I didn't find this function in Amplify.
Most helpful comment
This looks to be resolved with at least the latest version.