fix(tiles): pause/cap tile retries when offline (#136) - #189
Open
bernardogv wants to merge 1 commit into
Open
Conversation
…Lens#136) When the device is fully offline, tile fetches fail with a SocketException ("Failed host lookup") and TileLayerManager kept scheduling the normal 2s->4s->... backoff and logging on every failed tile, spamming the log. Detect offline-type errors (SocketException or a "Failed host lookup" message) in onTileLoadError, and while offline: - cap the retry timer at the existing _maxRetryDelay (60s) instead of the climbing backoff, so retries stay infrequent - only log the "scheduling retry" line once, on the transition into offline Offline state clears on the next successful tile load (onTileLoadSuccess). No new dependencies: the app has no connectivity package, so offline is inferred from the error itself. Adds an offline-detection test group. Generated with Claude Code
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.
Fixes #136.
Problem
When the device is fully offline (airplane mode, no signal), tile fetches throw
SocketException: Failed host lookup.TileLayerManagertreated these like transient errors: it kept the 2s→4s→…→60s backoff climbing and printed a "scheduling retry" line on every failed tile, spamming the log with DNS failures.Change
The app has no connectivity package, so offline is inferred from the error itself (no new dependency):
onTileLoadErrorclassifies an error as offline when it is aSocketExceptionor its message containsFailed host lookup.scheduleRetryarms the timer at the existing_maxRetryDelay(60s) instead of the climbing delay, so retries stay infrequent.onTileLoadSuccess).Existing behavior for transient (online) errors and the
TileLoadCancelledException/TileNotAvailableOfflineExceptionearly-returns is unchanged.Tests
Adds a
TileLayerManager offline detectiongroup (mocktail +FakeAsync, matching the existing test style): the offline flag is set on aSocketException/ "Failed host lookup", cleared on success, ordinary errors stay online, and the retry is capped at 60s rather than firing at 2s while offline. Full suite green (flutter test),flutter analyzeclean.Open question for maintainers
Without a connectivity package, "offline" is inferred from the error type/message. If you'd prefer an explicit signal (e.g.
connectivity_plus) or a different cap policy, happy to adjust.Generated with Claude Code