bencbartlett/Overmind

Task#isWorking sometimes throws

MadaraUchiha opened this issue · 1 comments

Issue summary

Task#(get) isWorking sometimes throws TypeErrors.

Description of issue:

Sometimes, presumably at the same tick a creep dies, an error is thrown in Task#isWorking that you cannot access pos of undefined. Happens to me for the GoToRoom task but I assume it could happen for others as well.

Full error below.

Steps to reproduce:

Just run a new colony for a while. They pop up often.

Error message:

TypeError: Cannot read property 'pos' of undefined
    at TaskGoToRoom.get isWorking [as isWorking] (main:3700:27)
    at TaskGoToRoom.run (main:3683:18)
    at Zerg.run (main:19374:30)
    at RandomWalkerScoutOverlord.autoRun (main:7107:19)
    at RandomWalkerScoutOverlord.run (main:14152:14)
    at try (main:23946:41)
    at Overseer.try (main:23664:17)
    at Overseer.run (main:23946:25)
    at _Overmind.run (main:24045:7133)
    at main (main:24298:14): Cannot read property 'pos' of undefined
// Offending line: main:3700:27
return this.creep.pos.inRangeToPos(this.targetPos, this.settings.targetRange) && !this.creep.pos.isEdge;

Suggested fix (optional):

Ensure that this.creep is not undefined prior to accessing its position. There's an assumption that it would always be there that is apparently false.

Other information:

  • Overmind version: {found in package.json or by typing info() into console}

    ‣ Version: Overmind v0.5.2
    ‣ Checksum: 0x34e6838c39d
    ‣ Assimilated: No (clearance code: null) [WIP]
    ‣ Operating mode: automatic

  • Commit hash: {optional, but helpful: include the commit hash (if known)}

    Taken from the 0.5.2 Release page. (So I'm guessing the commit which is tagged 0.5.2)

It's worth noting that this reproduces on the private server that you spawn from npx screeps start, doesn't seem to happen on the public server.