MagicMirrorOrg / MagicMirrorOrg/MagicMirror
[Bug] All items not loading when calendar loading fails
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 23.9k
- Forks
- 4.6k
- Avg merge
- 17h 31m
- Merged PRs (30d)
- 25
Description
Environment
MagicMirror² version: 2.37.0
Node version: 26.3.0
npm version: 11.16.0
Platform: Raspberry Pi OS and MacOS
Which start option are you using?
node --run start
Are you using PM2?
Yes
Module
calendar
Have you tried disabling other modules?
- Yes
- No
Have you searched if someone else has already reported the issue on the forum or in the issues?
- Yes
What did you do?
When i started up the program on my mirror all of a sudden all modules wouldn't load anymore. I tried disabling all other modules and found that the issue was in the calendar module.
What did you expect to happen?
I expected everything to startup as usually where all modules load.
What actually happened?
When the calendar has no entry for a single day, the while loop in the calendar module does not increment the counter and it gets into an infinite loop. That causes the whole system to become stuck and stop loading the calendar and other modules.
while (daysCollected < this.config.limitDays) {
const dateStr = currentDate.format("YYYY-MM-DD");
// Check if there are events on the currentDate
if (eventsByDate[dateStr] && eventsByDate[dateStr].length > 0) {
// If there are any events today then get all those events and select the currently active events and the events that are starting later in the day.
newEvents.push(...eventsByDate[dateStr].filter((ev) => this.timestampToMoment(ev.endDate).isAfter(moment())));
// Since we found a day with events, increase the daysCollected by 1
daysCollected++; // <---- THIS LINE SHOULD BE OUTSIDE THIS IF STATEMENT
}
// Search for the next day
currentDate.add(1, "day");
}
Additional comments
I have made a fix for this so i will submit this in the coming days when i find the time for it. Should be quite soon since it is only a one line fix.
Participation
- I am willing to submit a pull request for this change.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the calendar module at the date-collection while loop shown in the issue, focusing on behavior when a day has no events. Verify the change with a calendar containing an empty day and confirm that the remaining modules finish starting instead of the loop hanging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100