Skip to content

fix: modules losing data after HTTP 304 responses#4180

Merged
khassel merged 3 commits into
MagicMirrorOrg:developfrom
KristjanESPERANTO:http304
Jun 6, 2026
Merged

fix: modules losing data after HTTP 304 responses#4180
khassel merged 3 commits into
MagicMirrorOrg:developfrom
KristjanESPERANTO:http304

Conversation

@KristjanESPERANTO
Copy link
Copy Markdown
Collaborator

@KristjanESPERANTO KristjanESPERANTO commented Jun 5, 2026

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 were 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.
@khassel khassel merged commit 5d11b5d into MagicMirrorOrg:develop Jun 6, 2026
12 checks passed
@KristjanESPERANTO KristjanESPERANTO deleted the http304 branch June 6, 2026 18:15
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.

2 participants