Open vgribok opened 1 year ago
Thanks for opening an issue, @vgribok.
There are a few points here I want to address:
Now, regarding the actual behavior observed here. If the credentials are expired and need to be refreshed while the client is offline, this is not a use case we've explored deeply yet on the Amplify team (https://github.com/aws-amplify/amplify-flutter/issues/760), but we do have some meetings scheduled to review this across all our libraries.
I will leave this ticket open to track documentation of fetchAuthSession
and will post updates regarding offline behavior here and on #760.
Many thanks, @dnys1! To clarify, in this case the session is not yet expired - the device is just offline.
Vlad.
Ah, understood. I believe then, that the getAWSCredentials
flag is the culprit. This is also something we're looking into so that these partial refresh failures can be better handled.
Thanks. The credentials are not requested in my flow.
static Future<AuthSession> _attemptToGetAuthSession() =>
Amplify.Auth.fetchAuthSession()
.timeout(const Duration(seconds: 10));
Super similar issue here (same steps and crash) however it throws with the call to:
Amplify.Auth.fetchUserAttributes()
POST https://cognito-idp.us-east-2.amazonaws.com/? failed: SocketException: Failed host lookup: 'cognito-idp.us-east-2.amazonaws.com' (OS Error: No address associated with hostname, errno = 7)
@seanhamstra - Does this happen with a stable internet connection? If yes, can you reproduce this consistently?
If there is no network the expected behavior would be a thrown Exception of type NetworkException. It appears that currently the exception being thrown is a AWSHttpException. Other than the incorrect exception type, this appears to be functioning as expected.
@Jordan-Nelson apologies, you are correct. This is when we are offline. Previously we were only expecting AuthException
and thought we handled this case (before 1.0.0). Perhaps it was always throwing this and we missed the test case. Either way, AWSHttpException throws and we now catch any exception. Thanks!
@seanhamstra - it should throw an AuthException. NetworkException (which is what should be thrown) implements AuthException. However, it is throwing the wrong exception (AWSHttpException). We have a fix in progress. In the next release you should be able to just catch AuthException again.
Description
Just did
flutter pub upgrade
, using amplify_corev.1.0.0-next.2+1.
fetchAuthSession() on Android Pixel 3a emulator with Airplane mode on, with user successfully logged in in a prior app session, followed by app shutdown and restart. Getting:I really think that fetchAuthSession() docs should specify not only what the function does in general, but also what behavior is expected, including exceptions thrown, in different circumstances, like session has expired, like user is not logged in, like the device is offline, etc - all in one place.
Categories
Steps to Reproduce
Screenshots
No response
Platforms
Android Device/Emulator API Level
API 32+
Environment
Dependencies
Device
Android Pixel 3a emulator
OS
Android API 33
Deployment Method
Amplify CLI
CLI Version
10.6.0
Additional Context
No response
Amplify Config
Instructions unclear. Also, high amount of detail in this submission discourages contributions.