NPC Invader causes RangeError: Maximum call stack size exceeded



  • I've actually had this happen to me twice now, although I'm still not positive on why this happens. As far as I can tell though, the npc invader parks itself on the room border where my creep is trying to enter the room, and once my creep enters the room it ends up on the same tile as the npc invader which I'm assuming causes the error.

    Previously when this happened, my scripts would break any time I had vision of that npc invader and was trying to add it to a list. I wasn't able to be online when I started getting emails of script execution terminating and the RangeError, but looking at the replay I could see that a similar situation happened where one of my creeps was entering the same tile as the npc invader.

    My guess is that it has something to do with having multiple creeps on the same tile, and a possible fix may be to not allow npc creeps to move back on to exit tiles after they spawn and move off of them.



  • Actually, looking at the replay further as well as my stat tracking/when I started getting emails, the npc invader appears to have caused the issue right when it spawned.

    The replay: https://screeps.com/a/#!/history/W34S1?t=15902500

    There is no data before that, but ticks to live on the npc invader suggests it spawned in the room just before I got the first slew of emails of brokenness, and that happened a while before it ended up on the room border stacked with my creeps coming in to the room.



  • Don't you use custom moving functions? I used some recurrent calls inside my wrapper around moveTo, smth like:

    Creep.prototype.moveTo2(...) {
    /* some calculations */
    if(/* all is ok */) { /* move by own path */ }
    else reset(), this.moveTo2(...); // retry
    }

    Sometimes it caused call stack limit overflow due to some conditions (because of borders, cpu limit tick skipping etc.).