Improve episode sync error handling #711
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR should improve the reliability of our episode sync.
In my testing, all the calls to sync episode data were failing and a NoSuchElementException was getting logged. I think there are two separate causes of this, and fixing either of them solves the issue. This PR includes both fixes.
The first fix is that although we were calling
onErrorReturnItem
with our sync poller (which syncs the episode status every 60 seconds), that handler would complete the polling, causing sync to stop. The better approach is to handle the error inside theconcatMap
call because that way the polling doesn't stop if there is an error.The second fix is that, in my testing, every time I call the
sync/update_episode
endpoint, I would get theNoSuchElementException
. It sounds like this can be an issue with using aSingle
without a response body. Changing this to be aCompletable
resolved the problem.The problem is that I feel pretty confident that I'm missing something there because as far as I can tell, this code hasn't changed recently, and I find it unlikely that sync has been as broken as I'm experiencing that entire time, so maybe there is something I'm doing that is uniquely making this problem appear.
Basically, please look at these changes with a skeptical eye, particularly the changes to the
sync/update_episode
endpoint, since the additional error handling on its own is sufficient to fix the bug. I just made the second change to avoid throwing and catching an error on every API call to that endpoint, but we can easily and safely remove that change (I put it in a separate commit for exactly that reason).Testing Instructions
Verify the problem
Verify the fix
Checklist
modules/services/localization/src/main/res/values/strings.xml
I have tested any UI changes...
Related issue: #616