Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No internet connexion" case not handled in amazon-cognito-identity-js ? #558

Closed
jimshell opened this issue Mar 30, 2018 · 5 comments · Fixed by #605
Closed

"No internet connexion" case not handled in amazon-cognito-identity-js ? #558

jimshell opened this issue Mar 30, 2018 · 5 comments · Fixed by #605
Labels
Auth Related to Auth components/category bug Something isn't working
Projects

Comments

@jimshell
Copy link

jimshell commented Mar 30, 2018

Hi,

Using Amplify Auth to sign users in, I've just run a few tests with no internet connexion (by setting Chrome to "offline"), and I noticed that the promise on Auth.signIn was not rejected properly, so catch() was never fired.

I had a proper look at the error in console:

OPTIONS https://cognito-idp.eu-central-1.amazonaws.com/ net::ERR_INTERNET_DISCONNECTED
Uncaught (in promise) TypeError: Cannot read property 'headers' of undefined

The second error shows that in Client.js, the fetch catch does not handle the possibility of no headers at all =>
var code = (response.headers.get('x-amzn-errortype') || 'UnknownError').split(':')[0];

chokes on this one, and never calls the callback with an error.
Which then does not reject the signIn promise (or any other promise for any other method that relies on this)

I assume that Client.js should check that headers are indeed received first, and if not, callback an error, so that promise based code can later handle the "No internet connection" properly. The signIn call currently fails silently, which is not good in terms of UX...

Thank you!

@powerful23 powerful23 added bug Something isn't working Cognito Related to cognito issues labels Mar 30, 2018
@saxenankit123
Copy link

Hello jimshell - I am also stuck with this same issue ! Any luck on solution ?

@jimshell
Copy link
Author

jimshell commented Apr 9, 2018

Hello saxenankit123,

I have not tried to find any temporary workaround for this, I'm confident that the AWS/Amplify Team will sort this out quickly :)

The only thing I can think of at the moment would be to use a timeout wrapper around the signin call, and consider it "failed due to network" if it does not complete within the given time range (could be 10, 15, 30s... 10s is already pretty long in my opinion)
This is hackish but it should work OK - at least users would eventually be notified that they couldn't sign in "due to network".

But again, please give the AWS/Amplify Team some time to address this issue properly ;)

Cheers,
Jimshell

@mlabieniec mlabieniec added Auth Related to Auth components/category and removed Cognito Related to cognito issues labels Apr 19, 2018
@mlabieniec mlabieniec added this to Backlog in aws-amplify via automation Apr 19, 2018
@mlabieniec mlabieniec added this to the aws-amplify@0.4 milestone Apr 19, 2018
@mlabieniec
Copy link
Contributor

I believe this is related and should get merged soon:
#605

aws-amplify automation moved this from Backlog to Released Apr 19, 2018
@jimshell
Copy link
Author

Excellent! Thank you! :)

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Auth Related to Auth components/category bug Something isn't working
Projects
No open projects
aws-amplify
  
@beta
Development

Successfully merging a pull request may close this issue.

5 participants