fix(network): retry transient connection/IO failures to api.meshtastic.org#5870
Merged
Conversation
…c.org Both the Android (Android engine) and Desktop (Java engine) Ktor clients installed HttpRequestRetry with only retryOnServerErrors + exponentialDelay, so transient connection/IO failures (DNS blips, dropped sockets, read timeouts) surfaced immediately as errors instead of being retried — the common failure mode on flaky cellular. Add retryOnException(retryOnTimeout = true) alongside the existing 5xx rule, sharing the same MAX_RETRIES (3). Ktor's Java-engine IOException retry is reliable since 3.1/3.2 (KTOR-6770) and the repo is on 3.5.0. Centralize the policy as a single configureDefaultRetry() extension in core/network HttpClientDefaults (where the shared timeout/retry constants already live) so both engines share one definition instead of duplicating the install block. Co-Authored-By: Claude Opus 4.8 <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.
Why
Both Ktor
HttpClientconfigs (Android engine on mobile, Java engine on desktop) installedHttpRequestRetrywith onlyretryOnServerErrors(maxRetries = 3)+exponentialDelay(). Transient connection/IO failures toapi.meshtastic.org— DNS blips, dropped sockets, read timeouts — were therefore not retried and surfaced immediately as failures. That is the common failure mode on flaky cellular, where a single retry would usually succeed.Ktor's Java-engine
IOExceptionretry became reliable in 3.1/3.2 (KTOR-6770) and this repo is on Ktor 3.5.0, so enabling exception retry is now safe on both engines.Changes
🐛 Bug Fixes
retryOnException(maxRetries = 3, retryOnTimeout = true)alongside the existingretryOnServerErrorsrule so transient connection/IO/timeout failures are retried with the same backoff.maxRetriesreuses the existingHttpClientDefaults.MAX_RETRIES, so it stays in lockstep with the server-error rule.🛠️ Refactoring & Architecture
HttpRequestRetryConfig.configureDefaultRetry()extension incore/network'sHttpClientDefaults— where the shared timeout/retry constants already live — and call it from both engines. Previously each engine duplicated theinstall(HttpRequestRetry) { … }block; now there is one definition, so the two clients can't drift.Files
core/network/.../HttpClientDefaults.kt— newconfigureDefaultRetry()extension (commonMain;ktor-client-coreis already a commonMain dep)androidApp/.../di/NetworkModule.kt— call site nowinstall(plugin = HttpRequestRetry) { configureDefaultRetry() }desktopApp/.../di/DesktopKoinModule.kt— call site nowinstall(HttpRequestRetry) { configureDefaultRetry() }Testing Performed
Baseline verification run locally (worktree):
./gradlew spotlessApply✅./gradlew detekt✅./gradlew assembleDebug✅./gradlew :core:network:allTests✅ (56 tests)./gradlew :desktopApp:compileKotlin✅ (verifies the Java-engine call site compiles)No behavioral change beyond retry coverage; no new tests added (the change is wiring on the Ktor plugin config).
🤖 Generated with Claude Code