Closed vcrepin closed 9 months ago
This is the place that it fails according to Sentry trace
I found the problem.
The phone had the data economy feature on. This prevented the calls in the background to succeed.
Hey, @vcrepin 👋. Glad you already found the problem and unblocked yourself! Also, thank you for creating this issue because I've actually never read about the Data Saver feature within Android devices. Appreciate the education moment!
For anyone that comes across this issue, please refer to the Android docs to learn more about Data Saver mode. While it can reduce data usage by limiting background data and optimizing foreground app data usage, that restriction on the background data can affect performance and network calls. Looks like Cognito calls were impacted in this situation when the app was bring brought back to foreground.
I'll close this issue as resolved since you unblocked yourself so quickly, but feel free to comment back if that's not the case @vcrepin! Thanks.
Before opening, please confirm:
JavaScript Framework
Angular
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth
Backend
Amplify CLI
Environment information
Describe the bug
I use amplify auth for an angular app. After signIn, I refresh the session with fetchAuthSession() each 5 min or when the app has been put to background and put back to foreground. The app is packaged as a PWA. This works well everywhere except on my android phone (chrome browser). When the app is put back to foreground and refreshAuthSession is called it fails with the following error:
Unexpected end of JSON input
I can see that this is raised in the library fetch method and I also see in the logs that the call to
POST https://cognito-idp.us-east-1.amazonaws.com/ [504]
returned a 504 error.
The expiration of my tokens is quite long (many hours) so they should not be expired.
The problem happens when I leave the app in the background a certain time and work on other apps before putting it back to foreground.
Expected behavior
Should refresh the session as it does on all other plateforms
Reproduction steps
Start app on cell phone (PWA) put it to background play with other apps put back app to foreground
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
Chrome (PWA)
Mobile Browser Version
No response
Additional information and screenshots
No response