[calendar] refactor: migrate CalendarFetcher to ES6 class and improve error handling#3959
Merged
khassel merged 1 commit intoMagicMirrorOrg:developfrom Nov 14, 2025
Merged
Conversation
… error handling
1. Convert CalendarFetcher from legacy constructor function pattern to ES6 class,
which simplifies future migration to ES modules.
2. Implement targeted HTTP error handling with smart retry strategies for common
calendar feed issues:
- 401/403: Extended retry delay (5× interval, min 30 min)
- 429: Retry-After header parsing with 15 min fallback
- 5xx: Exponential backoff (2^count, max 3 retries)
- 4xx: Extended retry (2× interval, min 15 min)
- Add serverErrorCount tracking for exponential backoff
- Error messages now include specific HTTP status codes and calculated retry delays
for better debugging and user feedback
Previously, CalendarFetcher did not respond appropriately to HTTP errors, continuing
to hammer endpoints without backoff, potentially overloading servers and triggering
rate limits. This refactoring implements respectful retry strategies that adapt to
server responses and reduce unnecessary load.
khassel
approved these changes
Nov 14, 2025
Collaborator
|
Awesome work, thank you! |
Merged
sdetweil
added a commit
that referenced
this pull request
Jan 1, 2026
Thanks to: @Blackspirits, @Crazylegstoo, @jarnoml, @jboucly, @JHWelch, @khassel, @KristjanESPERANTO, @rejas, @sdetweil, @xsorifc28⚠️ This release needs nodejs version >=22.21.1 <23 || >=24 [Compare to previous Release v2.33.0](v2.33.0...develop) [core] Prepare Release 2.34.0 (#3998) dependency update + adjust Playwright setup + fix linter issue (#3994) demo with gif (#3995) [core] fix: allow browser globals in config files (#3992) [core] fix: restore --ozone-platform=wayland flag for reliable Wayland support (#3989) [core] auto create release notes with every push on develop (#3985) [core] chore: simplify Wayland start script (#3974) [gitignore] restore the old Git behavior for the default modules (#3968) [core] configure cspell to check default modules only and fix typos (#3955) [gitignore] restoring the old Git behavior for the CSS directory (#3954) feat(core): add server:watch script with automatic restart on file changes (#3920) [check_config] refactor: improve error handling (#3927) refactor: replace express-ipfilter with lightweight custom middleware (#3917) refactor: replace module-alias dependency with internal alias resolver (#3893) [dependencies] [chore] update dependencies and min. node version (#3986) [core] bump dependencies into december (#3982) Bump actions/checkout from 5 to 6 (#3972) Update deps, unpin parse5 (#3934) [core] Update deps and pin jsdom to v27.0.0 (#3925) chore: update dependencies (#3921) update deps, exclude node v23 (#3916) remove eslint warnings, add npm publish process to Collaboration.md (#3913) feat: add ESlint rule no-sparse-arrays for config check (#3911) chore: bump dependencies into october (#3909) [logging] logger: add calling filename as prefix on server side (#3926) [logger] Add prefixes to most Log messages (#3923) [modules/alert] Add new pt and pt-BR translations for Alert module and update global PT strings (#3965) [modules/calendar] add checksum to test whether calendar event list changed (#3988) [calendar] fix: prevent excessive fetching on client reload and refactor calendarfetcherutils.js (#3976) [calendar] refactor: migrate CalendarFetcher to ES6 class and improve error handling (#3959) [calendar] Show repeatingCountTitle only if yearDiff > 0 (#3949) [tests] suppress debug logs in CI environment + improve calendar symbol test stability (#3941) [calendar] chore: remove requiresVersion: "2.1.0" (#3932) [calendar] test: remove "Recurring event per timezone" test (#3929) [modules/compliments] [compliments] refactor: optimize loadComplimentFile method and add unit tests (#3969) fix: set compliments remote file minimum delay to 15 minutes (#3970) [compliments] fix: duplicate query param "?" in compliments module refresh url (#3967) [modules/newsfeed] [newsfeed] fix header layout issue (#3946) [modules/weather] [weatherprovider] update subclass language use override (#3914) [weather] fix wind-icon not showing in pirateweather (#3957) [weather] add error handling to weather fetch functions, including cors (#3791) remove deprecated ukmetoffice datapoint provider, cleanup .gitignore (#3952) fixes problems with daylight-saving-time in weather provider openmeteo (#3931) Fix for envcanada Provider to use updated Env Canada URL (#3919) [weather] feat: add configurable forecast date format option (#3918) [testing] testing: update "Enforce Pull-Request Rules" workflow (#3987) [core] refactor: replace XMLHttpRequest with fetch and migrate e2e tests to Playwright (#3950) [test] replace node-libgpiod with serialport in electron-rebuild workflow (#3945) [ci] Add concurrency to automated tests workflow to cancel outdated runs (#3943) [tests] migrate from jest to vitest (#3940) --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Karsten Hassel <[email protected]> Co-authored-by: Kristjan ESPERANTO <[email protected]> Co-authored-by: Ryan Williams <[email protected]> Co-authored-by: Veeck <[email protected]> Co-authored-by: Bugsounet - Cédric <[email protected]> Co-authored-by: Marc Landis <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: HeikoGr <[email protected]> Co-authored-by: Pedro Lamas <[email protected]> Co-authored-by: veeck <[email protected]> Co-authored-by: Magnus <[email protected]> Co-authored-by: Ikko Eltociear Ashimine <[email protected]> Co-authored-by: DevIncomin <[email protected]> Co-authored-by: Nathan <[email protected]> Co-authored-by: mixasgr <[email protected]> Co-authored-by: Savvas Adamtziloglou <[email protected]> Co-authored-by: Konstantinos <[email protected]> Co-authored-by: OWL4C <[email protected]> Co-authored-by: BugHaver <[email protected]> Co-authored-by: BugHaver <[email protected]> Co-authored-by: Koen Konst <[email protected]> Co-authored-by: Koen Konst <[email protected]> Co-authored-by: dathbe <[email protected]> Co-authored-by: Marcel <[email protected]> Co-authored-by: Kevin G. <[email protected]> Co-authored-by: Jboucly <[email protected]> Co-authored-by: Jboucly <[email protected]> Co-authored-by: Jarno <[email protected]> Co-authored-by: Jordan Welch <[email protected]> Co-authored-by: Blackspirits <[email protected]> Co-authored-by: Samed Ozdemir <[email protected]>
rejas
pushed a commit
that referenced
this pull request
Jan 29, 2026
This migrates the Newsfeed module to use the centralized HTTPFetcher class (introduced in #4016), following the same pattern as the Calendar module. This continues the refactoring effort to centralize HTTP error handling across all modules. ## Changes **NewsfeedFetcher:** - Refactored from function constructor to ES6 class (like the calendar module in #3959) - Replaced manual fetch() + timer handling with HTTPFetcher composition - Uses structured error objects with translation keys - Inherits smart retry strategies (401/403, 429, 5xx backoff) - Inherits timeout handling (30s) and AbortController **node_helper.js:** - Updated error handler to use `errorInfo.translationKey` - Simplified property access (`fetcher.url`, `fetcher.items`) **Cleanup:** - Removed `js/module_functions.js` (`scheduleTimer` no longer needed) - Removed `#module_functions` import from package.json ## Related Part of the HTTPFetcher migration effort started in #4016. Next candidate: Weather module (client-side → server-side migration).
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.
Previously, CalendarFetcher did not respond appropriately to HTTP errors, continuing to hammer endpoints without backoff, potentially overloading servers and triggering rate limits. This refactoring implements respectful retry strategies that adapt to server responses and reduce unnecessary load.
Maybe we could later centralize the HTTP error handling and use it for weather and newsfeed as well.
The PR was inspired by having worked on the calendar fetcher for MMM-CalendarExt2, where there was already better error handling.