Skip to content

fix(tiles): pause/cap tile retries when offline (#136) - #189

Open
bernardogv wants to merge 1 commit into
FoggedLens:mainfrom
bernardogv:fix/136-pause-tile-retries-when-offline
Open

fix(tiles): pause/cap tile retries when offline (#136)#189
bernardogv wants to merge 1 commit into
FoggedLens:mainfrom
bernardogv:fix/136-pause-tile-retries-when-offline

Conversation

@bernardogv

Copy link
Copy Markdown

Fixes #136.

Problem

When the device is fully offline (airplane mode, no signal), tile fetches throw SocketException: Failed host lookup. TileLayerManager treated 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):

  • onTileLoadError classifies an error as offline when it is a SocketException or its message contains Failed host lookup.
  • While offline, scheduleRetry arms the timer at the existing _maxRetryDelay (60s) instead of the climbing delay, so retries stay infrequent.
  • The "scheduling retry" log line is printed only once, on the transition into offline.
  • Offline state clears on the next successful load (onTileLoadSuccess).

Existing behavior for transient (online) errors and the TileLoadCancelledException / TileNotAvailableOfflineException early-returns is unchanged.

Tests

Adds a TileLayerManager offline detection group (mocktail + FakeAsync, matching the existing test style): the offline flag is set on a SocketException / "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 analyze clean.

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

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pause tile retries when device is offline

1 participant