Console logging within an infinite loop causes client to freeze
-
(Yes, I am a naughty programmer for not making sure that my recursive function actually had a base case. Don't run the code that I included below without a plan for recovering.)
I was working on automating the process of figuring out what components my factory would need to produce to get to an end product and I added the following to the end of my main script.
factory_requirement = function(res) { console.log("To make " + res + " we need:"); for (k in COMMODITIES[res].components) { console.log(k); console.log(COMMODITIES[res].components[k]); if (k in COMMODITIES) factory_requirement(k); } } factory_requirement(RESOURCE_WIRE);
This causes infinite recursion because wire requires utrium bars, which require utrium which can be made by decompressing utrium bars. Fortunately the server seems to handle this well. Unfortunately the client will freeze and I was unable to comment out the initial call to factory_requirement to fix my code.
I'm using a machine running Windows 10. Both the Steam client and the screeps.com website froze when I attempted to open a room.