Skip to content

[Bug] All items not loading when calendar loading fails #4243

Description

@deBasMan21

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions