You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Background sync is triggered and fails behind the scenes if the user logs out while having unsynced items.
To Reproduce
Steps to reproduce the behavior:
Login to the Avni app
Let sync complete
Perform a registration/encounter
Logout without syncing
Every hour background sync will be attempted and will fail (and will notify bugsnag).
Expected behavior
Background sync should not occur when user is logged out.
Additional context
Current logic only checks if userId is set or not which works if user has never logged in but does not work if user has logged in once and then logs out.
We should probably modify the code so that the job itself is only scheduled after login and cancelled on logout instead of relying on other states.
Logs
This was a case of an encounter with media.
INFO [7:37:12:445] [Sync][Info] Starting background sync
INFO [7:37:12:448] [Sync][Info] Starting SyncService
INFO [7:37:12:448] [Sync][Info] Getting SyncService
DEBUG [7:37:12:449] [BaseService][Debug] Dispatching action: "SYNC.ON_BACKGROUND_SYNC_STATUS_CHANGE"
INFO [7:37:12:450] [Sync][Info] Getting connection info
INFO [7:37:12:452] [Sync][Info] Calling syncService.sync
DEBUG [7:37:12:452] [SyncService][Debug] sync
DEBUG [7:37:12:459] [BaseService][Debug] Dispatching action: "SyncTelemetryActions.START_SYNC"
DEBUG [7:37:12:463] [mediaUploadRequired][Debug] true
DEBUG [7:37:12:465] [BaseService][Debug] Dispatching action: "SYNC.ON_BACKGROUND_SYNC_STATUS_CHANGE"
DEBUG [7:37:12:467] [MediaQueueService][Debug] Number of media queue items: 2
INFO [7:37:12:467] [MediaQueueService][Info] Upload batch size 1
DEBUG [7:37:12:468] [FileSystem][Debug] /storage/emulated/0/Android/data/com.openchsclient/files/Avni/media/images/
DEBUG [7:37:12:470] [Requests][Debug] Calling getText: https://staging.avniproject.org/media/uploadUrl/755e8b5c-8017-496d-b0a1-1c56cd2d5e37.jpg
ERROR MediaQueueService undefined, "Error while uploading f3edf5d1-ef83-491f-a78c-ed47fa2f164b - 755e8b5c-8017-496d-b0a1-1c56cd2d5e37.jpg"
ERROR MediaQueueService No user or needs login, {"authErrCode":"No User","authErrDate":"2023-11-29T02:07:12.475Z"} Error: No user or needs login
at AuthenticationError (http://10.0.2.2:8081/index.android.bundle//&platform=android&dev=true&minify=false&app=com.openchsclient&modulesOnly=false&runModule=true:193185:29)
at anonymous (http://10.0.2.2:8081/index.android.bundle//&platform=android&dev=true&minify=false&app=com.openchsclient&modulesOnly=false&runModule=true:193684:56)
at tryCallOne (/root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/Release/4i495j47/x86/lib/InternalBytecode/InternalBytecode.js:53:16)
at anonymous (/root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/Release/4i495j47/x86/lib/InternalBytecode/InternalBytecode.js:139:27)
at apply (native)
at anonymous (http://10.0.2.2:8081/index.android.bundle//&platform=android&dev=true&minify=false&app=com.openchsclient&modulesOnly=false&runModule=true:39142:26)
at _callTimer (http://10.0.2.2:8081/index.android.bundle//&platform=android&dev=true&minify=false&app=com.openchsclient&modulesOnly=false&runModule=true:39021:17)
at _callReactNativeMicrotasksPass (http://10.0.2.2:8081/index.android.bundle//&platform=android&dev=true&minify=false&app=com.openchsclient&modulesOnly=false&runModule=true:39066:17)
at callReactNativeMicrotasks (http://10.0.2.2:8081/index.android.bundle//&platform=android&dev=true&minify=false&app=com.openchsclient&modulesOnly=false&runModule=true:39272:44)
at __callReactNativeMicrotasks (http://10.0.2.2:8081/index.android.bundle//&platform=android&dev=true&minify=false&app=com.openchsclient&modulesOnly=false&runModule=true:3206:46)
at anonymous (http://10.0.2.2:8081/index.android.bundle//&platform=android&dev=true&minify=false&app=com.openchsclient&modulesOnly=false&runModule=true:2980:45)
at __guard (http://10.0.2.2:8081/index.android.bundle//&platform=android&dev=true&minify=false&app=com.openchsclient&modulesOnly=false&runModule=true:3179:15)
at flushedQueue (http://10.0.2.2:8081/index.android.bundle//&platform=android&dev=true&minify=false&app=com.openchsclient&modulesOnly=false&runModule=true:2979:21)
at invokeCallbackAndReturnFlushedQueue (http://10.0.2.2:8081/index.android.bundle//&platform=android&dev=true&minify=false&app=com.openchsclient&modulesOnly=false&runModule=true:2973:33)
DEBUG [7:37:12:483] [ErrorHandler][Debug] IsFatal=true Error: syncTimeoutError
DEBUG [7:37:12:483] [ErrorHandler][Debug] syncTimeoutError
DEBUG [7:37:12:491] [ErrorHandler][Debug] Creating frame array
DEBUG [7:37:12:491] [ErrorHandler][Debug] Notifying Bugsnag Error: Fatal error: syncTimeoutError
WARN Possible Unhandled Promise Rejection (id: 2):
Error: Fatal error: syncTimeoutError
Error: Fatal error: syncTimeoutError
Developer Checklist
Developer fixing the bug should fill this checklist.
Does the fix require extensive regression testing?
Are you mentioning the required scenarios that could be affected?
The text was updated successfully, but these errors were encountered:
Describe the bug
Background sync is triggered and fails behind the scenes if the user logs out while having unsynced items.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Background sync should not occur when user is logged out.
Additional context
Current logic only checks if userId is set or not which works if user has never logged in but does not work if user has logged in once and then logs out.
We should probably modify the code so that the job itself is only scheduled after login and cancelled on logout instead of relying on other states.
Logs
This was a case of an encounter with media.
Developer Checklist
Developer fixing the bug should fill this checklist.
The text was updated successfully, but these errors were encountered: