<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[electronSwitches in config.js — am I reading the code wrong, or does it not actually work?]]></title><description><![CDATA[<p dir="auto">Dear all,</p>
<p dir="auto">I have been chasing a runaway Electron disk cache on my Mirror (Pi 5, MM 2.34.0) and added what I thought was the obvious fix to my config.js:</p>
<pre><code>electronSwitches: ["disk-cache-size", "104857600"],   // 100 MB
</code></pre>
<p dir="auto">Some months later the cache had grown to 2 GB (260,000+ files in  ~/.config/Electron/Cache/Cache_Data/).<br />
My limit appeared to be ignored entirely.</p>
<p dir="auto">When I looked at js/electron.js line 47 I think I see why, but I want to sanity-check this with the community  — maybe I am   simply misreading the code.</p>
<p dir="auto">The line is:</p>
<pre><code>app.commandLine.appendSwitch(...new Set(electronSwitchesDefaults, config.electronSwitches));
</code></pre>
<p dir="auto">As far as I understand it, two things are happening here:</p>
<ol>
<li>new Set(a, b) silently drops the second argument.</li>
</ol>
<p dir="auto">The Set constructor signature is new Set([iterable]) — it accepts exactly one iterable. Any further arguments are ignored. So I believe this is   equivalent to:</p>
<pre><code>new Set(electronSwitchesDefaults)
</code></pre>
<p dir="auto">and config.electronSwitches never makes it in.<br />
Is that right?<br />
Or am I missing some clever JavaScript I have not seen before?</p>
<ol start="2">
<li>appendSwitch only takes one switch per call.</li>
</ol>
<p dir="auto">The Electron docs state the signature is appendSwitch(switch, value?). Spreading a flat array of multiple switches into a single call should — if I   understand correctly — only honour the first switch/value pair and silently discard the rest.</p>
<p dir="auto">The defaults array ([“autoplay-policy”, “no-user-gesture-required”]) happens to be exactly one switch with one value, so that one works. But   anything a user adds via config.electronSwitches would never take effect, even if point 1 were fixed.</p>
<p dir="auto">If both readings are correct, the natural fix would be a loop, something like:</p>
<pre><code>const switches = &lsqb;&lsqb;"autoplay-policy", "no-user-gesture-required"], ...(config.electronSwitches || [])];
switches.forEach(([s, v]) =&gt; app.commandLine.appendSwitch(s, v));
</code></pre>
<p dir="auto">or, if electronSwitches is documented as a flat array, the user-facing schema would need to be specified more clearly first.</p>
<p dir="auto">My questions to the forum:</p>
<ul>
<li>Is my reading of new Set(a, b) correct here?</li>
<li>Has anyone successfully used electronSwitches to actually change Electron behaviour, and if so, with what syntax?</li>
<li>Is this maybe legacy code that the community has worked around in other ways I am not aware of?</li>
</ul>
<p dir="auto">Thanks,<br />
Ralf</p>
]]></description><link>https://forum.magicmirror.builders/topic/20259/electronswitches-in-config.js-am-i-reading-the-code-wrong-or-does-it-not-actually-work</link><generator>RSS for Node</generator><lastBuildDate>Thu, 04 Jun 2026 19:24:16 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/20259.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Jun 2026 12:05:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to electronSwitches in config.js — am I reading the code wrong, or does it not actually work? on Thu, 04 Jun 2026 12:28:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a> That should already be fixed in the develop branch by <a href="https://github.com/MagicMirrorOrg/MagicMirror/pull/4161" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/MagicMirrorOrg/MagicMirror/pull/4161</a> and will be in the next release. It would be great if you could switch to the develop branch and test it before the release :) Good analysis, by the way!</p>
]]></description><link>https://forum.magicmirror.builders/post/131271</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/131271</guid><dc:creator><![CDATA[KristjanESPERANTO]]></dc:creator><pubDate>Thu, 04 Jun 2026 12:28:26 GMT</pubDate></item><item><title><![CDATA[Reply to electronSwitches in config.js — am I reading the code wrong, or does it not actually work? on Thu, 04 Jun 2026 16:56:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> , <a class="plugin-mentions-user plugin-mentions-a" href="/user/kristjanesperanto" aria-label="Profile: kristjanesperanto">@<bdi>kristjanesperanto</bdi></a> ,<br />
I’ve decided to resolve it by myself - with Sam’s hint/advice/helper-file.<br />
It seems to work - will double check my cache size in a few days.</p>
<p dir="auto">Thanks again for your great support.<br />
Migration is a bigger task and wihout any need currently too much - even cache-growth wouldn’t change this.</p>
<ul>
<li>never touch a running system :-)</li>
</ul>
<p dir="auto">Warm regards,<br />
Ralf</p>
]]></description><link>https://forum.magicmirror.builders/post/131286</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/131286</guid><dc:creator><![CDATA[rkorell]]></dc:creator><pubDate>Thu, 04 Jun 2026 16:56:45 GMT</pubDate></item><item><title><![CDATA[Reply to electronSwitches in config.js — am I reading the code wrong, or does it not actually work? on Thu, 04 Jun 2026 16:55:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a> don’t touch your old card. Backup, Make new,<br />
Install MagicMirror, restore, test. Fallback to old card if you need to</p>
<p dir="auto">As safe as it gets</p>
]]></description><link>https://forum.magicmirror.builders/post/131284</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/131284</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 04 Jun 2026 16:55:06 GMT</pubDate></item><item><title><![CDATA[Reply to electronSwitches in config.js — am I reading the code wrong, or does it not actually work? on Thu, 04 Jun 2026 16:41:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> OK, thanks!<br />
Still doesn’t sound THAT safe …</p>
<p dir="auto">regards,<br />
Ralf</p>
]]></description><link>https://forum.magicmirror.builders/post/131283</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/131283</guid><dc:creator><![CDATA[rkorell]]></dc:creator><pubDate>Thu, 04 Jun 2026 16:41:34 GMT</pubDate></item><item><title><![CDATA[Reply to electronSwitches in config.js — am I reading the code wrong, or does it not actually work? on Thu, 04 Jun 2026 15:02:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a></p>
<p dir="auto">its already 2.36 now… we put out a sep release to fix a bunch of things.<br />
2.37 is july 1</p>
<p dir="auto">copy the MM folder to save so you don’t  lose anything</p>
<p dir="auto">use my upgrade script</p>
<p dir="auto">my backup/restore will move things too</p>
<p dir="auto">no functional 3rd party module content changed,<br />
modules didn’t move location<br />
just location of default modules (you shouldn’t care)<br />
and USER files, config.js, custom.css  now in ONE folder instead of 2</p>
<p dir="auto">I have to fix my MMM-Config for the electronSwitches structure change(before july 1), already fixed for css move and default modules move.</p>
<p dir="auto">must you may ALSO need new OS to support new nodejs and electron…</p>
<p dir="auto">my backup/restore will help put the old config on new system after new MM install</p>
<p dir="auto">backup existing, store on github., versioned too, not only copy on sd card.<br />
make new sd card<br />
boot<br />
install MM, make sure it runs<br />
restore (from github) (it reinstalls modules, this is NOT a binary backup, just text very small)<br />
restart MM</p>
]]></description><link>https://forum.magicmirror.builders/post/131279</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/131279</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 04 Jun 2026 15:02:19 GMT</pubDate></item><item><title><![CDATA[Reply to electronSwitches in config.js — am I reading the code wrong, or does it not actually work? on Thu, 04 Jun 2026 14:50:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> , yes.<br />
I’ve really thought about this.</p>
<p dir="auto">How do you see the update?<br />
I’m currently on 2.34.<br />
Switch to 2.35 is SUBSTANCIAL !</p>
<ul>
<li>changes of standard-module location, changes of location for custom.css, electron new …</li>
</ul>
<p dir="auto">Will this break my system?<br />
Or am I fine with just using your great update-script?<br />
Thanks for any advice (I KNOW that you cannot provide any guarantee. I’m just interested in gut-feeling…)</p>
<p dir="auto">(and: if it brake: is there a way back??? )</p>
<p dir="auto">Warmest regards,<br />
Ralf</p>
]]></description><link>https://forum.magicmirror.builders/post/131278</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/131278</guid><dc:creator><![CDATA[rkorell]]></dc:creator><pubDate>Thu, 04 Jun 2026 14:50:32 GMT</pubDate></item><item><title><![CDATA[Reply to electronSwitches in config.js — am I reading the code wrong, or does it not actually work? on Thu, 04 Jun 2026 14:16:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a> so much fun!!! you can code it to maybe fix your problem.</p>
<p dir="auto">net, the new electronSwitches is still an array , but now contains an object for the key:value pair, or just a string for those switches that are just single value</p>
<pre><code>[ 
   "string"
   { "id":"value"].,
   ...
]
</code></pre>
<p dir="auto">and the<br />
appendSwitch can be either single string</p>
<pre><code>commandLine.appendSwitch(sw);
</code></pre>
<p dir="auto">or two part,</p>
<pre><code>commandLine.appendSwitch(name, String(value));
</code></pre>
<p dir="auto">code here in a sep function<br />
<a href="https://github.com/MagicMirrorOrg/MagicMirror/blob/develop/js/electron_helper.js" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/MagicMirrorOrg/MagicMirror/blob/develop/js/electron_helper.js</a></p>
]]></description><link>https://forum.magicmirror.builders/post/131277</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/131277</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 04 Jun 2026 14:16:57 GMT</pubDate></item><item><title><![CDATA[Reply to electronSwitches in config.js — am I reading the code wrong, or does it not actually work? on Thu, 04 Jun 2026 13:42:54 GMT]]></title><description><![CDATA[<p dir="auto">Dear Sam, <a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a>,<br />
thanks to you as well!</p>
<p dir="auto">As mentioned above: A little bit shy …</p>
<p dir="auto">Warmest regards,<br />
Ralf</p>
]]></description><link>https://forum.magicmirror.builders/post/131276</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/131276</guid><dc:creator><![CDATA[rkorell]]></dc:creator><pubDate>Thu, 04 Jun 2026 13:42:54 GMT</pubDate></item><item><title><![CDATA[Reply to electronSwitches in config.js — am I reading the code wrong, or does it not actually work? on Thu, 04 Jun 2026 13:41:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kristjanesperanto" aria-label="Profile: KristjanESPERANTO">@<bdi>KristjanESPERANTO</bdi></a><br />
Thanks!<br />
To be honest, I’m hesitating with upgrades …<br />
And pulling develop branches ist defnitely not my favourite way of using my mirror.</p>
<p dir="auto">I even refused to install the last reelase- caused by the major changes in config.js location …</p>
<p dir="auto">I will think about, but …<br />
mmmmhhmmmm…</p>
<p dir="auto">Thanks anyway for your feedback - highly appreciated!</p>
<p dir="auto">Warmest regards,<br />
Ralf</p>
]]></description><link>https://forum.magicmirror.builders/post/131275</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/131275</guid><dc:creator><![CDATA[rkorell]]></dc:creator><pubDate>Thu, 04 Jun 2026 13:41:30 GMT</pubDate></item><item><title><![CDATA[Reply to electronSwitches in config.js — am I reading the code wrong, or does it not actually work? on Thu, 04 Jun 2026 13:14:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a> to switch to develop see<br />
<a href="https://forum.magicmirror.builders/topic/14327/testing-new-fixes-or-solving-current-problems-with-next-release-code">https://forum.magicmirror.builders/topic/14327/testing-new-fixes-or-solving-current-problems-with-next-release-code</a></p>
]]></description><link>https://forum.magicmirror.builders/post/131273</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/131273</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 04 Jun 2026 13:14:41 GMT</pubDate></item><item><title><![CDATA[Reply to electronSwitches in config.js — am I reading the code wrong, or does it not actually work? on Thu, 04 Jun 2026 12:28:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a> That should already be fixed in the develop branch by <a href="https://github.com/MagicMirrorOrg/MagicMirror/pull/4161" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/MagicMirrorOrg/MagicMirror/pull/4161</a> and will be in the next release. It would be great if you could switch to the develop branch and test it before the release :) Good analysis, by the way!</p>
]]></description><link>https://forum.magicmirror.builders/post/131271</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/131271</guid><dc:creator><![CDATA[KristjanESPERANTO]]></dc:creator><pubDate>Thu, 04 Jun 2026 12:28:26 GMT</pubDate></item></channel></rss>