Skip to content

fix(http-fetcher): fall back to reloadInterval after retries exhausted#4113

Open
KristjanESPERANTO wants to merge 3 commits intoMagicMirrorOrg:developfrom
KristjanESPERANTO:fix/http-fetcher
Open

fix(http-fetcher): fall back to reloadInterval after retries exhausted#4113
KristjanESPERANTO wants to merge 3 commits intoMagicMirrorOrg:developfrom
KristjanESPERANTO:fix/http-fetcher

Conversation

@KristjanESPERANTO
Copy link
Copy Markdown
Collaborator

As reported in #4109, the weather module retries much more frequently than expected after network errors. #4092 already fixed the main cause (duplicate fetchers), but the backoff logic in HTTPFetcher still has a gap: once retries are exhausted, calculateBackoffDelay keeps returning a short fixed delay (60s) instead of falling back to reloadInterval. The same problem existed for 5xx errors, where the delay grew to 8× the configured interval.

Inspired by #4110 (thanks @CodeLine9), this PR makes both error paths fall back to reloadInterval after retries are exhausted. I also simplified the catch block, extracted a #shortenUrl() helper for log messages, and added tests for the backoff progression.

When networkErrorCount or serverErrorCount reaches maxRetries,
calculateBackoffDelay produced a fixed short delay instead of
respecting the user's configured reloadInterval.

Skip backoff once retries are exhausted and use reloadInterval
directly. Both network and server error paths now use the same
calculateBackoffDelay strategy for consistency.
- Extract URL truncation into private #shortenUrl() method
- Use #shortenUrl() consistently in all log messages
- Merge duplicate networkErrorCount >= maxRetries checks into a single
  if/else block that handles both delay calculation and logging
- Replace logFn.call(Log, ...) with explicit if/else for clarity
- Remove redundant inline JSDoc for error event
Verify that both network and server errors fall back to reloadInterval
after maxRetries is reached, and that error counts reset on success.
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.

1 participant