Describe the bug
We are currently on the process of upgrading our aws-amplify library from 1.1.9 to 1.1.36 and aws-amplify-react from 1.0.19 to 2.3.12 . We found the following issue where we will get Unhandled Rejection (Error) error from aws-amplify library when our user is redirected back to the app with OAuth flow error (e.g https://localhost:3000/?error_description=Error+in+SAML+response&error=server_error)
Additional context:
To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
React app will be freezed due to Unhandled Rejection (Error)
Our code
let amplifyConfig = {
Auth: {
identityPoolId: Config.cognito.IDENTITY_POOL_ID,
region: Config.cognito.REGION,
userPoolId: Config.cognito.USER_POOL_ID,
userPoolWebClientId: Config.cognito.APP_CLIENT_ID,
mandatorySignIn: true,
cookieStorage: {
domain: Config.reactApp.COOKIE_DOMAIN,
path: '/',
expires: 1,
secure: Config.reactApp.SECURE_PROTOCOL
},
oauth: {
domain : Config.cognito.USERPOOL_HOSTED_DOMAIN+'.auth.'+Config.cognito.REGION+'.amazoncognito.com',
scope : [ 'openid', 'email' ],
redirectSignIn : Config.cognito.USERPOOL_ADFS_CALLBACK_URL,
redirectSignOut : Config.cognito.USERPOOL_ADFS_LOGOUT_URL,
responseType: 'code',
}
},
Analytics: {
disabled: true,
autoSessionRecord: false,
}
};
Amplify.configure(amplifyConfig)
Screenshots



I'm having the same issue, there is no trycatch or componentDidCatch that helps to prevent the app to freeze
@rabellino12 please +1 for this issue.
However, this issue doesn't affect our production build as in production environment the error won't frezee the entire stack. It does affect our local development though
+1
@rabellino12 @hp0210 We are looking into this.
@rabellino12 @hp0210 - Just to be clear, the expected behavior here is for the application to load in an unauthenticated state (with the ideal case also being that the error from the url bubbles up through Amplify's standard error logging system). Is that correct?
Hi @haverchuck thanks for looking into it, yes, so we can handle custom rejections sent from pre signup trigger and give some feedback to the user about why the authentication/signup failed. Right now we get the message when listening to Hub events, but there is no way to prevent the unhandled rejection
@rabellino12 @hp0210 - I've put in a PR to fix this (a simple try/catch). It will probably be a bit before this winds its way to our release branch, but calling it out in case you want to take a look to unblock yourself.
Great, thank you @haverchuck
@rabellino12 @hp0210 - PR for this has been merged into our master branch, which means it should be available in npm under the '@unstable' tag as soon as it makes its way through our pipeline. We will get a release to the main build as soon as we can.
Exercise caution when using '@unstable', of course.
If for whatever reason this does not solve your problem, please post another issue. Thank you.