Automattic / Automattic/pocket-casts-android
Crash on logout race condition
- Dominant language
- Kotlin
- Stars
- 2.8k
- Forks
- 308
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 143
Description
### Description
In the watch app I have observed that occasionally logging out will cause a crash because it tries to get an access token [here](https://github.com/Automattic/pocket-casts-android/blob/5049b0109fa90c0074d5428a77ca990041cf39e8/modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/sync/SyncManagerImpl.kt#L522-L521), but fails because the refresh token is null. This appears to be a race condition since there is an earlier guard on this code confirming that the user is logged in.
I have only reproduced this on the watch app, but this is using the same logic as the phone app, so the same problem might be possible there. I have not been able to reproduce this on the phone app though.
### Step-by-step reproduction instructions
I cannot reproduce this consistently, but the steps I've been following taht seems to cause it the most consistently are (note that all of the details in these steps probably aren't necessary, I'm just reporting what I've been doing):
3. Log into the watch app using google sign in
4. Log out of the watch app
5. If that doesn't crash, then log back into the google account and sign out again. On the watch app I get a crash within the first 2-3 signouts pretty consistently.
### Screenshots or screen recording
_No response_
### Did you search for existing bug reports?
- [X] I have searched for existing bug reports.
### Device, Operating system, and Pocket Casts app version
Watch emulator with a 7.39 pre-release build.
Contributor guide
Research direction
Inspect modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/sync/SyncManagerImpl.kt around line 522, starting with the access-token lookup and the earlier logged-in guard. Use the watch emulator with the 7.39 pre-release build to repeat the reported sign-in and logout cycles; done means those cycles no longer crash when the refresh token is null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100