feat(sdk): rethrow publishProfileAndMark + publishAndMark for eager onboarding banner#99
Open
variablefate wants to merge 4 commits intomainfrom
Open
feat(sdk): rethrow publishProfileAndMark + publishAndMark for eager onboarding banner#99variablefate wants to merge 4 commits intomainfrom
variablefate wants to merge 4 commits intomainfrom
Conversation
…ublishAndMark Onboarding watchdog (ADR-0016) inferred publish failure from a sync-store dirty flag because both `publishProfileAndMark` and `publishAndMark` swallowed errors at the SDK boundary. Even an instant relay rejection left the user staring for the full 60s window before the banner appeared. Promote the two helpers to `async throws`. AppState's onboarding path catches and runs the same connectivity-gated check the watchdog uses, firing the banner immediately when online (and deferring to the watchdog's offline-park branch when not). The watchdog stays as the hang-case safety net. `ProfileBackupCoordinator.publishAndMark` preserves its republish-loop coalescing semantic via a last-iteration error: a coalesced republish that succeeds rescues an earlier failed iteration; only a terminal failure throws. Non-onboarding callers (`SyncCoordinator.flushPendingSyncPublishes`, `SyncDomainStrategy.publishLocal`, settings/locations UI taps) wrap with `try?` to preserve their best-effort contract. ADR-0017 documents the change. Closes #97 item 2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
Code reviewFound 1 issue:
roadflare-ios/RoadFlare/RoadFlareCore/ViewModels/AppState.swift Lines 441 to 447 in dbca1d4 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Pre-PR-99 the two `await` calls swallowed errors internally so both ran unconditionally. After the throws migration, `try await publishProfile()` short-circuited the chain — `publishProfileBackup()` never ran when the first call failed, leaving the Kind 30177 backup unattempted until a manual Retry or the next reconnect-flush. Capture the first error, run both publishes, throw if either failed. The eager-error catch in `runOnboardingPublishImpl` still surfaces the banner when at least one fails. Addresses code review feedback on PR #99. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… pattern
Both methods silently no-op when the sync coordinator isn't configured,
but `publishProfile` made it explicit via `guard let ... else { return }`
while `publishProfileBackup` relied on optional-chaining a throwing call,
which silently returns nil-coalesced Void without throwing. Same end
state, but the explicit guard reads better and matches the sibling.
Code review follow-up on PR #99.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
Owner
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
- ProfileBackupCoordinator: capture `generationStillValid` inside the atomic-exit lock so the post-loop throw decision uses state from the same critical section, restoring the "atomic single-lock exits" contract that .claude/CLAUDE.md mandates for publish state machines. - AppState: update `startOnboardingPublish` doc to acknowledge that the publish is no longer "unsupervised" — the eager-error catch block (ADR-0017) is a second failure-surface path that runs concurrently with the watchdog. - AppState: update `onboardingPublishTask` doc to reflect that cancellation matters at three places now (entry-bail + two checks bracketing the connectivity await in the catch block), not just pre-scheduling. Code-review follow-up. No behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
RoadflareDomainService.publishProfileAndMarkandProfileBackupCoordinator.publishAndMarkfromasynctoasync throws. Onboarding (runOnboardingPublishImpl) catches and fires the banner immediately when online instead of waiting the full 60s for the watchdog. ADR-0016's watchdog stays as the hang-case safety net.ProfileBackupCoordinator.publishAndMarkpreserves its republish-loop coalescing via a last-iteration-error semantic: a coalesced republish that succeeds rescues an earlier failure; only a terminal failure throws. Sessions invalidated byclearAll()return without throw.SyncCoordinator.flushPendingSyncPublishes,SyncDomainStrategy.publishLocal, settings/locations UI taps inSettingsTab/PaymentMethodsScreen/SavedLocationsView) wrap withtry?to preserve best-effort contract — the dirty flag is still the source of truth there.publishXAndMarkhelpers stayasync(no UI watchdog observes them).OnboardingPublishWatchdogTestsgets two new tests: eager-fire-when-online and stay-quiet-when-offline-then-rearm.ADR-0017 documents the decision and rationale. Closes Issue #97 item 2.
Test plan
swift test(838 tests) — all pass; newpublishProfileAndMarkRethrowsRelayFailuretest exercises the throw, existingpublishAndMarkFailurePathSkipsMarkPublishedupdated to expect the throw.xcodebuild ... test(full iOS test plan) — all pass; neweagerErrorSurfacesBannerBeforeWatchdogTimeoutWhenOnlineasserts banner fires in <500ms with timeout configured to 60s (production value),eagerErrorStaysQuietWhenOfflineasserts watchdog parking owns the offline path.🤖 Generated with Claude Code