@o4kapuk
I've looked further into the issue and I think I've found it.
I think it's caused by providing the energyStructures towards the spawnCreep call, and one of the extensions that you pass has no energy and therefore an empty store object.
In the "newEnergyHandling" method you have this code:
let availableEnergy = _.sum(energyStructures, id => roomObjects[id].store.energy);
if(availableEnergy < cost) {
return false;
}
and a bit further:
let energyChange = Math.min(cost, energyStructure.store.energy);
energyStructure.store.energy -= energyChange;
bulk.update(energyStructure, {store:{energy: energyStructure.store.energy}});
The lodash _.sum seems to be very robust and handles null/undefined without a problem.
A Math.min() with undefined in it will give NaN, so I think this is were the problem originates from.
When not providing energy structures to the spawnCreep call I can't reproduce the issue, so If it's not what I described above there's definitely something else wrong in there.