@silentium_noxe Looping over Game.screeps after calling Spawn.createCreep and accessing any proprety defined here would cause that error. So even simple stuff like .hits would cause the error.
As for the code: nothing wrong with it, I do it all the time. I recommend running your spawning logic after your creep logic (this helps avoid running out of cpu as well, if you have too many creeps you run out of cpu before you can run your spawning logic, which will intern cause you to spawn fewer creeps).
You can also iterate over rooms then iterate over Room.find(FIND_MY_CREEPS), rather than all of your creeps all at once.
Finally if you want to iterate over creeps that are spawning. I personally iterate over my spawns and check the spawning property and access the Creep that way, since there a fewer Spawns than Creeps.