fix(data): separate refresh timeouts from Room persistence#5881
Merged
jamesarich merged 2 commits intoJun 20, 2026
Conversation
Bound only the remote API calls with timeouts in DeviceHardwareRepository and DeviceLinkRepository refresh paths. Local Room persistence completes outside those deadlines via NonCancellable context, preventing timeout cancellation from interrupting local database writes during connection startup.
Brings the branch up to date with main and resolves the lone conflict in DeviceLinkRepositoryImplTest.kt by taking main's wall-clock harness (runBlocking + Dispatchers.Unconfined, from meshtastic#5883). The branch's runTest(UnconfinedTestDispatcher) variant would reintroduce the Room ioDispatcher virtual-clock flake meshtastic#5883 fixed; the test set is otherwise identical, so no coverage is lost. The refresh-timeout / NonCancellable production changes merge cleanly and are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jamesarich
approved these changes
Jun 20, 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.
Overview
This PR separates remote refresh timeouts from local Room persistence for device hardware and device-link cache refreshes.
Previously, refresh code could apply a timeout around the whole stale-while-revalidate operation, including local cache writes. That meant a refresh deadline could cancel while Room persistence was already in progress.
This change bounds only the remote API calls and lets local cache persistence complete outside those deadlines.
Key Changes
staleWhileRevalidateFlowcallers to opt out of the helper-level timeout when the fetch lambda manages its own remote timeout.DeviceHardwareRepositoryImplso the remote hardware API call is timeout-bound, while hardware Room persistence runs outside that timeout.DeviceLinkRepositoryImplso the remote device-link API call is timeout-bound, while local upsert/prune persistence runs outside that timeout.Notes
This is independent from WiFi/TCP handshake recovery and was split out from #5856 to keep that PR focused on the core connection recovery changes. I plan to land this first, then rebase #5856 so the extracted hunks drop out cleanly.