Skip to content

[Bug] Calendar module fails with "Cannot read properties of undefined (reading 'guess')" in v2.34.0 #4035

@amarand

Description

@amarand

Environment

MagicMirror² version: 2.34.0
Node version: v22.21.1
npm version: 10.9.4; pm2: 5.x
Platform: Raspberry Pi 5 running Raspberry Pi OS (Trixie/Debian 13)

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?

  1. Installed MagicMirror v2.34.0 fresh on Raspberry Pi 5 (Trixie)
  2. Configured the calendar module with CalendarLabs US Holidays feed:
   {
     module: "calendar",
     header: "US Holidays",
     position: "top_left",
     config: {
       calendars: [
         {
           symbol: "calendar-check",
           url: "https://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics"
         }
       ],
       fade: false
     }
   }
  1. Started MagicMirror with PM2
  2. Calendar module displayed error message instead of events

What did you expect to happen?

The calendar module should display upcoming US holidays from the iCal feed. This same configuration worked correctly in MagicMirror v2.31.0 (tested same morning before upgrade).

What actually happened?

Calendar module shows error: "Error in the calendar module. Check logs for more details."

Console shows:

[ERROR] [calendar] Calendar Error. Could not fetch calendar: https://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics TypeError: Cannot read properties of undefined (reading 'guess')
    at Object.calculateTimezoneAdjustment (/home/sgoodman/MagicMirror/modules/default/calendar/calendarfetcherutils.js:24:31)

Additional comments

Root Cause

In modules/default/calendar/calendarfetcherutils.js, line 5 imports moment:

const moment = require("moment");

However, line 24 calls moment.tz.guess() which requires the moment-timezone library:

event.start.tz = moment.tz.guess();

Since moment-timezone is not imported, moment.tz is undefined, causing the error.

Proposed Fix

Change line 5 in modules/default/calendar/calendarfetcherutils.js from:

const moment = require("moment");

To:

const moment = require("moment-timezone");

I've tested this fix locally and it resolves the issue completely. The calendar module now loads and displays events correctly.

Participation

  • I am willing to submit a pull request for this change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions