Fix/165 168 idempotency and race fixes - #324
Open
whisper011 wants to merge 4 commits into
Open
Conversation
…its a check-in or vault create (ethos-protocol#165)
|
@whisper011 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
Fixes four correctness bugs around offline sync and auth token refresh on Android and iOS:
PendingActionSyncWorkercan double-submit a check-in or duplicate-create a vault if the process dies mid-sync #165 —PendingActionSyncWorkercould double-submit a check-in or duplicate-create a vaultif the process died between the server accepting the request and the local queue row being
deleted. Adds a client-generated
X-Idempotency-Key(stable across retries, unlikeX-Nonce)and a
syncedflag so a row that already succeeded is cleaned up on the next run withoutresubmitting the request or double-counting it in sync diagnostics.
CheckInSyncTask/PendingCheckInStorehas the same crash-window duplicate-submission risk #166 — iOSCheckInSyncTask/PendingCheckInStorehad the same crash-window risk. Adds thesame idempotency key to
PendingCheckIn, threaded throughAPIClient.checkIn/createVault,and makes a corrupted queue file (captured mid-write) surface as
lastLoadWasCorruptedinsteadof silently being treated as an empty queue.
CREATE_VAULTpending actions have no dedupe key, so a double-tap while offline creates two vaults #167 —CREATE_VAULTpending actions had no dedupe key, so a double-tap of "Create Vault"while offline queued two identical actions and created two real vaults. Adds an in-flight guard
(
VaultUiState.isCreatingVault) so a second tap can't reach the network/queue while the firstcall is still pending.
/auth/refresh,with no ordering guarantee on which response won. Adds single-flight protection
(
Mutex+CompletableDeferred) so concurrent callers share one in-flight refresh.Test plan
PendingActionSyncWorkerTest,CheckInSyncWorkerTest,VaultViewModelTest,ApiClientTestcover idempotency-key resubmission, synced-row dedupe, double-tapcreate-vault guarding, and single-flight token refresh.
CheckInSyncTaskTestscovers idempotency-key resubmission after a simulated crashand corrupt-queue-file detection.
mismatch, no Swift toolchain available) — please run the test suites in CI before merging.
Closes #165
Closes #166
Closes #167
Closes #168