Skip to content

fix(data): separate refresh timeouts from Room persistence#5881

Merged
jamesarich merged 2 commits into
meshtastic:mainfrom
jeremiah-k:bugfix/data-refresh-timeouts
Jun 20, 2026
Merged

fix(data): separate refresh timeouts from Room persistence#5881
jamesarich merged 2 commits into
meshtastic:mainfrom
jeremiah-k:bugfix/data-refresh-timeouts

Conversation

@jeremiah-k

Copy link
Copy Markdown
Contributor

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

  • Allows staleWhileRevalidateFlow callers to opt out of the helper-level timeout when the fetch lambda manages its own remote timeout.
  • Updates DeviceHardwareRepositoryImpl so the remote hardware API call is timeout-bound, while hardware Room persistence runs outside that timeout.
  • Updates DeviceLinkRepositoryImpl so the remote device-link API call is timeout-bound, while local upsert/prune persistence runs outside that timeout.
  • Keeps device-link refresh as upsert-then-prune; no transactional device-link replacement path is added.
  • Updates device-link repository tests for isolated dispatchers/fixtures.

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.

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.
@github-actions github-actions Bot added the bugfix PR tag label Jun 20, 2026
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 jamesarich enabled auto-merge June 20, 2026 17:20
@jamesarich jamesarich added this pull request to the merge queue Jun 20, 2026
Merged via the queue into meshtastic:main with commit 63dbbdd Jun 20, 2026
22 checks passed
@jeremiah-k jeremiah-k deleted the bugfix/data-refresh-timeouts branch June 20, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants