TypeError: Cannot read property 'length' of undefined



  • Lol, how much memory are you using? I doubt that an error with your code would ever go without causing a traceback. It's probably either the memory or something weird with the new runtime engine.



  • I'm using around 700KB at the moment. Last I benchmarked it, JSON.stringify on Memory was taking 12-15ms. These values don't seem to be substantially different when the problem is occuring, sometimes in solid bursts of 20-40 ticks at a time.



  • Oh, I've never thought of using JSON.stringify. I guess it's so fast, all the cool kids are doing it 😮

    Anyways, I restarted and am currently redoing my scripts, so I'm thinking of just limiting the amount of rooms and creeps I'm gonna use. It seems better than all my creeps moving at half-speed because of constant errors, for now.



  • This can definitely be caused by a call to lookAt(). I've got it narrows down to a spot where if I lookAt() a particular thing, then return, it crashes every time, vs if I just comment out the lookAt() before the return, everything is peachy.

    I'm still trying to figure out exactly which parameters to lookAt() cause the issue; there's no easy way for me to tell which one is causing the crash.



  • Eureka! This error essentially means "timeout during lookAt". Reproduce as follows:

    while (true) {
    Game.rooms.W5N4.lookAt(25, 25);
    }



  • ...That's really weird. I haven't been able to reproduce the error in W8N4, though. Have you tried the same code in other rooms?



  • Works for me in any room where I have creeps. Works from the console. Works if my script is otherwise empty. I can't find a way to make it not work, for me.



  • Well, you can just paste for(;;){} (or some other code that triggers an infinite loop, for that matter) into the console, and the exact same error will pop up.



  • Gah. Well, ummm..at least this verifies it is related to running out of CPU time, not some other cause?

    It would be nice to instead get the promised behavior of prior commands being executed and prior script output being shown, when you hit the CPU limit. I've seen that work properly in circumstances (of unknown nature) when the normal message instead of this one appeared.


  • Dev Team

    Thanks to all for reporting this and good reproducing work. Fixed.