fix: prevent crash during wallet backup#1092
Merged
Merged
Conversation
Member
Author
|
Waiting for upstream branch merge |
ben-kaufman
reviewed
Jul 17, 2026
ben-kaufman
reviewed
Jul 17, 2026
Member
Author
|
Tested from https://github.com/synonymdev/bitkit-android/actions/runs/29591563331 . My app stopped crashing |
jvsena42
marked this pull request as ready for review
July 22, 2026 10:28
jvsena42
enabled auto-merge
July 22, 2026 10:28
Greptile SummaryThis PR prevents Paykit state-read failures from escaping the wallet backup coroutine. The main changes are:
Confidence Score: 5/5This looks safe to merge.
|
| Filename | Overview |
|---|---|
| app/src/main/java/to/bitkit/repositories/BackupRepo.kt | Handles payload construction failures through the existing backup failure state path while preserving coroutine cancellation. |
| app/src/test/java/to/bitkit/repositories/BackupRepoTest.kt | Tests that a failed Paykit snapshot skips upload and clears the running backup state. |
| changelog.d/next/1092.fixed.md | Documents the automatic wallet backup crash fix. |
Reviews (1): Last reviewed commit: "fix: keep backup result type on snapshot..." | Re-trigger Greptile
jvsena42
disabled auto-merge
July 22, 2026 10:40
ben-kaufman
reviewed
Jul 22, 2026
ben-kaufman
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR fixes a crash that could put the app into a restart loop shortly after launch.
Description
The wallet backup payload was assembled outside of any error handling, so a failure while reading Paykit state escaped the backup coroutine and brought the whole app down. The automatic backup runs shortly after every launch, so an affected wallet crash-looped on startup with no way for the user to recover.
The payload is now built inside the existing failure handling. A failed read marks the backup as failed and retries later, the same way an upload failure already did. This also covers the retry action on the Backup settings screen, which previously crashed when tapped for a failed wallet backup.
The trigger seen in the wild was a stored Paykit session missing capabilities the SDK now requires, which is only reachable if Paykit was turned on from dev settings. The backup path itself is not gated, so any Paykit initialisation failure could take down the app the same way for any user.
Relationship to #1094
This branch was cut before #1094 merged, which is why the crash above was reachable at all: the backup scope had no exception handler, so the throw reached the system default handler and killed the process. #1094 has since been merged into this branch and now contains that throw.
The two fixes are complementary rather than overlapping. #1094 stops the process dying, but on its own it leaves the failure only logged, and the backup then retries every five seconds indefinitely because the category is never marked as failed. This PR is the concrete instance of the follow-up #1094 called out: guarding the specific background body so the failure is handled meaningfully instead of only logged.
The retry action on the Backup settings screen runs on the screen's view-model scope, which #1094 does not cover, so that path was fatal before #1094 and stays fatal without this PR.
Recovering a stale session and broader coroutine error handling are follow-ups (#1093). That includes the Paykit dependencies resolved when backup observation starts, which also run on a view-model scope and are still unguarded. This PR only stops the crash, so an affected wallet will report a failed wallet backup instead of crashing.
Preview
N/A — no user-facing UI changes.
QA Notes
Manual Tests
regression:Fresh launch with wallet activity → wait for automatic backup: Settings → Backup shows wallet backup synced, no crash.regression:Settings → Backup → tap retry on a failed wallet backup: retries without crashing.Automated Checks
BackupRepoTest.kt. Verified failing before the fix and passing after.