Repository navigation
Description
Environment
MagicMirror² version: 2.36.0
Node version: 24.14.1
npm version: 11.11.0
Platform: Raspbian
I updated to v2.36.0 this morning, and it broke one of my modules. Specifically, I have an MMM-CalendarExt2 module specified in my config.js, which calls a custom function within the config.js file to programatically set special icons for calendar entries. The module was working fine before the upgrade, but now it is reporting [ERROR] [MMM-LogExt] [ERROR] [:4:26] Uncaught ReferenceError: checkForCustomIcon is not defined (the function name is checkForCustomIcon; I have confirmed that the function exists and is named correctly. There are many other modules I use that also rely on functions inside the config.js file, and none of those seem to be affected. I don't know what's different about this.
Which start option are you using?
node --run start:wayland
Are you using PM2?
Yes
Module
None
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?
Configuration
Here is the relevant part of my module definition:
{
module: 'MMM-CalendarExt2',
config: {
calendars : [
{
name: "Family Calendar",
url: "https://calendar.google.com/calendar/ical/<redacted>",
icon: "ion:calendar-outline",
className: "calmain",
},
{
name: "US Holidays",
url: "https://calendar.google.com/calendar/ical/<redacted>",
icon: "mingcute:firework-line",
className: "calholiday",
},
{
name: "Birthdays",
url: "https://calendar.google.com/calendar/ical/<redacted>",
icon: "wpf:birthday",
className: "calbirthdays",
},
{
name: "Anniversaries",
url: "https://calendar.google.com/calendar/ical/<redacted>",
icon: "game-icons:diamond-ring",
className: "calanniversaries",
},
],
views: [
{
name: "week",
mode: "daily",
position: "lower_third",
slotCount: 7,
filterPassedEvent: true,
timeFormat:"h:mm A",
hideOverflow: false,
slotMaxHeight: "auto",
transform: (event) => {
const iconChoice = checkForCustomIcon (event)
if (iconChoice !== '') {
event.icon = iconChoice
}
if (event.title === "a") {
event.className = "calholiday"
event.icon = "mingcute:a"
}
return event;
},
},
],
scenes: [
{
name: "DEFAULT",
views: [],
},
],
},
},And at the bottom of the config.js file, I have this function defined:
function checkForCustomIcon (event) {
if (event.title.search("a") > -1 || event.title.search("b") > -1 || event.title.search("c") > -1 || event.title.search("d") > -1 || event.title.search("e") > -1 || event.title.search("e") > -1) {
return "icon-park-outline:a"
}
else if (event.title.search("f") > -1 || event.title.search("g") > -1) {
return "game-icons:b"
}
else if (event.title.search("h") > -1 || event.title.search("i") > -1 || event.title.search("j") > -1) {
return "hugeicons:c"
}
else if (event.title.search("k") > -1) {
return "iconoir:d"
}
else if (event.title.search("l") > -1) {
return "ri:e"
}
else if (event.title.search("m") > -1) {
return "ph:f"
}
return ''
}Did something change with how functions need to be formatted with the latest release?
Steps to reproduce the issue:
Include specific functions (no idea what the specific issue is) in your config.js
Upgrade to 2.36
What did you expect to happen?
MM picks up the function and properly parses the module definition.
What actually happened?
MM complains that the function is missing.
Additional comments
No response
Participation
- I am willing to submit a pull request for this change.
Activity
dathbe commentedon May 7, 2026
Possibly the result of something here? #4106
dathbe commentedon May 7, 2026
I think I might be on to something with #4106. I replaced all the
"with'. That didn't entirely fix my problem (the CalendarExt2 module is still not displaying on my mirror), but it did get rid of the "is not defined" error.sdetweil commentedon May 7, 2026
I have a config that does something similar for HomeAssistantDisplay.
| mine doesn't have functions referenced from config... it creates variables used in config
Can you move your function to before
config =
And see if the results are different
khassel commentedon May 7, 2026
Since
v2.35.0we use the/configendpoint to get theconfig.jscontent in the browser. #4106 was a fix inv2.36.0because the functions were missing.Problem: The
/configendpoint contains only the content of the config object and your function definition is outside of this object.I found this workaround (sorry for the bad formatting) which did not produce any errors in browser or backend, can you test this with real data?
dathbe commentedon May 8, 2026
Thanks for the suggestions. I'll try when I have a moment. Any idea why this one (of about 5-7) function isn't working while the others are? Do I need to migrate the rest of my functions to the
let config =format? And should we update the documentation to make this clear?khassel commentedon May 8, 2026
no, you did not provide the others so we can not test/debug
I don't know, test it. You can take a look into the
/configendpoint to see if/how they are displayed thereI haven't found anything in the documentation regarding custom functions in
config.js, though perhaps I simply overlooked it.sdetweil commentedon May 8, 2026
I don't think we have that doc. its sort of 'accidental'/nodejs stuff that functions will exist in a js file that was loaded with require/import
and people have leveraged it
and I think we will HAVE to document it now that we pre-process ONLY the config part..
KristjanESPERANTO commentedon Jun 27, 2026
That's my suggestion: MagicMirrorOrg/MagicMirror-Documentation#385
sdetweil commentedon Jul 1, 2026
I thought we fixed this in 2.37
khassel commentedon Jul 1, 2026
@sdetweil
Kristjan added the section in the docs.
Functions work if they are placed inside the
configblock but not outside. I provided a workaround but got no final feedback so far. From my side this can be closed as not planned.sdetweil commentedon Jul 14, 2026
@khassel I saw the example above using inside config.. didn't see workaround outside config.
khassel commentedon Jul 14, 2026
It might be a misunderstanding; the workaround applies to inside config — there isn't one for outside config.
sdetweil commentedon Jul 14, 2026
ok, didn't think so.. closing