-
Notifications
You must be signed in to change notification settings - Fork 199
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
fetchAuthSession fails after device wakes #3789
Comments
Would you be able to share you code snippet that is being used upon device getting awaked. Additionally, could you also share the metrics that you are seeing, if there is any specific logs or errors that could help narrow down the issue. |
Inside of a Task, it's basically just...
The error returned is what I mentioned in the context section above. There are no logs or analytics that I can share. The error is logged via analytics, which is how I got those same results posted above. And as I mentioned also, in this case, HubPayload.EventName.Auth.sessionExpired is NOT reported. |
We also have this issue. However, I have not yet found out the exact cause and cannot reproduce it. |
Thank you - it'd be great if you can share reproduction steps when you run into this issue again. |
Today I had the problem again on one of our test devices.
Our code at this point looks like this:
|
One more piece of information. |
@tobias-feldmann Do you think you would be able to get verbose logs for the scenario that you faced? You can enable verbose logging to the console by doing this before calling
|
@harsh62 |
@tobias-feldmann @kparichan Are you guys still facing this issue? |
Yes and no. We worked around the issue. If fetchAuthSession fails, and if we have the token from a previous call in memory, we just reuse that and ignore the error. If it is invalid, we rely on the backend to reject it when making our API call. If it's just a failure in the library, then the backend call will succeed. Not ideal, but it seems to be working. |
What do you do if the backend rejects it? Do you sign out and sign in? |
Depends on the circumstances, but usually ignored. We're subscribed to Hub for auth notifications, so if the session really is expired, we catch that and log them out then. |
I think in your case, after the device wakes up after a while, does the app actually restart because it feels you need to call I would check if the error is of type |
Amplify.configure is called every time the app is launched, and that's the only time. As for the error that's returned, as noted in my original description, it's just a generic "Amplify.AuthError error 1". |
This is a configuration error. Thats why I believe there is some sort of timing issue between the |
I understand what you're suggesting, but from what we've seen, if we just ignore the error once or twice, the error goes away without a configure call and fetchAuthSession successfully returns. During that time, the user is not reported as logged out by Hub, and the in memory token remains valid when passed to the backend. |
Cool.. For now I am gonna close the issue, please feel free to open another issue if you are seeing issues that are not recoverable. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
In our analytic reports we see fetchAuthSession failing after a device wakes up, and has been asleep for some time.
Additional info provided the "Additional context" section below.
This is not a new issue for us. It's been showing up intermittently for the last several months, across various versions of amplify-swift.
Steps To Reproduce
Expected behavior
Network connectivity is available, so fetchAuthSession should return a valid auth token or flag the user as not being signed in.
Amplify Framework Version
2.35.4
Amplify Categories
Auth
Dependency manager
Swift PM
Swift version
5.10
CLI version
12.1.0
Xcode version
15.4 (15F31d)
Relevant log output
Is this a regression?
No
Regression additional context
No response
Platforms
iOS
OS Version
No specific OS version
Device
No specific device
Specific to simulators
No response
Additional context
Information originally included in response to issue #3540.
The text was updated successfully, but these errors were encountered: