fix: modules losing data after HTTP 304 responses#4180
Open
KristjanESPERANTO wants to merge 3 commits into
Open
fix: modules losing data after HTTP 304 responses#4180KristjanESPERANTO wants to merge 3 commits into
KristjanESPERANTO wants to merge 3 commits into
Conversation
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.
d44dd45 to
b7006a4
Compare
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.
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:
response.json()