Skip to content

fix: modules losing data after HTTP 304 responses#4180

Open
KristjanESPERANTO wants to merge 3 commits into
MagicMirrorOrg:developfrom
KristjanESPERANTO:http304
Open

fix: modules losing data after HTTP 304 responses#4180
KristjanESPERANTO wants to merge 3 commits into
MagicMirrorOrg:developfrom
KristjanESPERANTO:http304

Conversation

@KristjanESPERANTO
Copy link
Copy Markdown
Collaborator

When a server responds with 304 (nothing changed since last fetch), the response has no body. Several modules were trying to parse that empty body anyway - which either cleared their cached data or threw an exception. The result: a blank calendar, empty newsfeed, or missing weather data after the next refresh cycle.

This was reported in the forum: https://forum.magicmirror.builders/topic/20250/calendar-events-broadcasting-nothing-showing

The bug was "introduced" by #4120, which correctly started forwarding 304s to consumers - but not all weren't ready for it.

Fix

Skip parsing on 304 and keep the existing data as-is:

  • calendar - re-broadcasts cached events
  • newsfeed - re-broadcasts cached items
  • buienradar, openmeteo, weatherflow, weathergov - return early before calling response.json()

When a calendar server responds with 304 (nothing changed since last
fetch), the response has no body. CalendarFetcher was parsing it anyway,
which produced an empty event list - clearing all previously loaded
events and showing nothing on screen.

The bug was hidden until MagicMirrorOrg#4120 started forwarding 304 responses through
HTTPFetcher instead of silently dropping them.

Fix: skip parsing on 304 and re-broadcast the cached events as-is.

Also adding unit tests for CalendarFetcher: 304 handling, HTTP error
forwarding, parse error resilience, and shouldRefetch boundaries.
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