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

Inconsistent sync complete toast #2942

Open
f-odhiambo opened this issue Dec 22, 2023 · 8 comments
Open

Inconsistent sync complete toast #2942

f-odhiambo opened this issue Dec 22, 2023 · 8 comments
Assignees
Labels
Bug Report Something isn't working as expected

Comments

@f-odhiambo
Copy link
Contributor

Describe the bug
After clicking sync(On the registers menu) two toast messages are shown "Sync complete" then a second later "Syncing"

To Reproduce
Steps to reproduce the behavior:

  1. Log in to Bidan, Eir and Cadre
  2. Click on the menu on the top left corner
  3. Click on sync
  4. Two toast messages are shown Sync complete the Syncing a second later(See attached screen cast)

Expected behavior
After clicking on sync the toast message syncing should be shown then later sync complete should show.

Recorder_21122023_131103.mp4
@f-odhiambo f-odhiambo added the Bug Report Something isn't working as expected label Jan 2, 2024
@kelvin-ngure
Copy link
Contributor

kelvin-ngure commented Jan 2, 2024

@f-odhiambo
What is happening is intentional due to a missing feature that is coming soon from the SDK. This SyncJobStatus file will show you the new ENQUEUED state coming soon

While there is an ENQUEUED WorkState for scheduled jobs, there is no such SyncJobStatus and as a result, when a job is enqueued, the RegisterFragment is instructed to mark it as FINISHED.

Since every job enters an ENQUEUED phase regardless of whether it is a periodicSync or oneTimeSync, the "Sync Complete" toast shows up immediately the jobs are enqueued. The oneTimeSync jobs quickly jump into STARTED state and so you see the "Syncing" on the UI. Then once the oneTimeSync is complete, the "Sync Complete" toast shows up for the second time

I've added some Timber entries in the code to demonstrate
image (1)

@kelvin-ngure
Copy link
Contributor

kelvin-ngure commented Jan 2, 2024

While looking at this, I spotted what I believe to be a bug or something that can make spotting sync issues harder. When you initially start the app, the sync ends in a FAILED state that is preceded by a GLITCH state. On the UI, the "Sync Completed" toast shows up but then a sync retry begins. The retry is expected since GLITCH should prompt a retry. I will look into the flow and figure out why the "Sync Complete" toast shows up even on failure when a GLITCH happens right before FAILED

image

@f-odhiambo @dubdabasoduba please let me know if we should show a "Sync Failed. Retrying..." toast or something during a Glitch as there is no handler for the GLITCH status

I've added some Timber entries in the code to demonstrate

The below shows that both types of job do enter an ENQUEUE phase so there probably be a different logic to handle them
image

The below shows the GLITCH phase (I have added a handler for it in the code). I am currently getting 403 and 502 errors on SID-EIR (currently following up with @f-odhiambo on that- my credentials may be bad or something else) and that is likely what causes the GLITCH. The retry is expected and that's why you see the manual oneTimeSync restart. However, as noted above, I will fix the issue where the UI shows "Sync Complete" even during a GLITCH and subsequent FAILED state

image

We may also need to decide how many times the app should retry sync after failure. It appears to retry indefinitely. Let me know if that is the case

@ndegwamartin
Copy link
Contributor

Related ticket here #2947

@dubdabasoduba
Copy link
Member

dubdabasoduba commented Jan 22, 2024

@kelvin-ngure did you stop getting the 403s and 502s mentioned in the comment above?

@kelvin-ngure
Copy link
Contributor

@dubdabasoduba no. I just sent you some logs

@kelvin-ngure
Copy link
Contributor

kelvin-ngure commented Feb 6, 2024

@ndegwamartin @f-odhiambo from What I see in the upgrade PR. To fix this, we would first need to migrate from using SyncJobStatus to using CurrentSyncJobStatus which has both work state and SyncJobStatus state representations. Is that migration something we are planning to do?

@ndegwamartin
Copy link
Contributor

@kelvin-ngure yeah this needs to be done. Created a ticket here to track this #3059. Feel free to update the ticket with other info needed.

@ndegwamartin
Copy link
Contributor

This is still blocked, see google/android-fhir#2472

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

4 participants