Repository navigation
Closed
Description
Environment
System Information
- SYSTEM: manufacturer: System manufacturer; model: System Product Name; virtual: false; MM: v2.37.0-develop
- OS: platform: linux; distro: Ubuntu; release: 22.04.5 LTS; arch: x64; kernel: 5.15.0-177-generic
- VERSIONS: electron: 42.1.0; used node: 24.15.0; installed node: 22.22.1; npm: 10.9.4; pm2: 5.4.3
- ENV: XDG_SESSION_TYPE: x11; MM_CONFIG_FILE: undefined
WAYLAND_DISPLAY: undefined; DISPLAY: :0.0; ELECTRON_ENABLE_GPU: undefined - RAM: total: 48076.70 MB; free: 40129.30 MB; used: 7947.40 MB
- OTHERS: uptime: 11076 minutes; timeZone: America/Chicago
[2026-05-18 14:18:58.875] [LOG] [electron] Launching applic
Which start option are you using?
node --run start:x11
Are you using PM2?
No
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
electronSwitches: {
"password-store": "basic",
"js-flags": "--max-old-space-size=8192"
},
<!-- Paste relevant code here -->Steps to reproduce the issue:
What did you expect to happen?
has been working for 'years' (or maybe not working)
What actually happened?
I added the console.log elsw...
[2026-05-18 14:18:58.876] [LOG] [electron] elsw { 'password-store': 'basic', 'js-flags': '--max-old-space-size=8192' }
[2026-05-18 14:18:58.877] [ERROR] [unknown] (node:725432) UnhandledPromiseRejectionWarning: TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
at createWindow (/home/sam/MagicMirror.2.36.dev/js/electron.js:49:39)
config.js
electronSwitches: {
"password-store": "basic",
"js-flags": "--max-old-space-size=8192"
},
from the electron doc , SOME switches are keyword/value
app.commandLine.appendSwitch('remote-debugging-port', '8315')
app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1')
so the config value cannot be flat array of single values.. ,, I think appendswitch of {'remote-debugging-port': '8315'} , would fail too
i'm guessing the old code didn't work either
let electronSwitchesDefaults = ["autoplay-policy", "no-user-gesture-required"];
app.commandLine.appendSwitch(...new Set(electronSwitchesDefaults, config.electronSwitches));
at least, the defaults were connected , "autoplay-policy":"no-user-gesture-required"
changing my switches to
electronSwitches: [
{"password-store": "basic"},
{"js-flags": "--max-old-space-size=8192"}
],
doesn't produce an error on startup, but I don't know if the switches are correctly passed..
Additional comments
No response
Participation
- I am willing to submit a pull request for this change.
Activity
KristjanESPERANTO commentedon May 18, 2026
Thanks Sam - yes, this is a real issue.
electronSwitcheswas broken since PR #2643 (thenew Set(...)swallowed the user config). #4136 only got it working like the way the docs claimed - array of strings - but as you point out, that design can't express switches with values, since Electron wantsappendSwitch(name, value).I think the cleanest fix is to just switch to an object. I'll take a look in the next days.
sdetweil commentedon May 18, 2026
I didn't see any electron examples of plain switch --foobar
but this heading lists some..
https://www.electronjs.org/docs/latest/api/command-line-switches#electron-cli-flags
does appendSwitch have an override for no value for the switch? or are these ONLY allowed on the commandline??
whats the difference between a switch and a flag? if they both can be done on the cli???
KristjanESPERANTO commentedon May 19, 2026
I checked this locally with Electron.
appendSwitchdoes seem to support both forms:That gives me:
{"noSandbox":true,"jsFlags":"--max-old-space-size=8192"}I also checked whether passing
name=valueas a single string would work:That does not register
js-flags; it registers the whole string as the switch name. So the current array-of-strings design really can't express switches with values.On "switch" vs "flag": I'm not sure there is a strict distinction here. Electron seems to use both terms for command-line args like
--nameor--name=value.So I still think an object form maps best to Electron's API:
I'll try to look into this soon more deeply and open a PR if it works out. Unless someone else wants to take a shot at it first :)
sdetweil commentedon May 19, 2026
I don’t like this but, js arrays support dissimilar things
[
"no-sandbox”,
{ "js-flags": "--max-old-space-size=8192"}
]
And it’ll be a pain to support in mmm-config
So if the array element is a string,
Then use the single form append
Else if object not array,
use the dual form, object_key, object_value
Else error
Then you dont have any ambiguity over the object value fake ‘true’ in
KristjanESPERANTO commentedon May 19, 2026
Okay, keeping the array is also a good choice. I've created #4161 :)
feat(electron): support object-based electronSwitches (#4161)
[-][Bug] 37 dev branch,. fails on electronSwitches[/-][+][Bug] 2.37 dev branch,. fails on electronSwitches[/+]sdetweil commentedon Jun 5, 2026
one thing, should we update js/defaults.js to add the electronSwitches variable?
are there others missing too, I can't keep up!
KristjanESPERANTO commentedon Jun 6, 2026
Good point. For the behavior it doesn't matter, but for clarity and consistency, it makes perfect sense to add the defaults. I've created #4181 to handle this :)
I'll also work on the relevant docs later - I noticed a few issues while preparing the PR.
chore: add missing core defaults (#4181)
KristjanESPERANTO commentedon Jun 6, 2026
And here is the docs PR: MagicMirrorOrg/MagicMirror-Documentation#383