Closed Darker closed 3 years ago
Weird, that shouldn't happen. What did you try to do to get that error ?
As I was saying, it happens randomly while the bot is digging. I did not manage to find some correlation with anything more specific.
Ok one case when it happens is when the bot is teleported while digging. The most common situation is when it dies.
I can't reproduce that error in these situation. I'm trying on a vanilla server. On what server did you have that error ?
Can't reproduce. If this happens again or you can provide a minimal example when it happens, reopen ;)
I just hit this too (bot.targetDigBlock null in finishDigging https://github.com/PrismarineJS/mineflayer/blob/master/lib/plugins/digging.js#L72) while testing voxel-clientmc, though I don't have a reproducible test case yet either, appears to be related to failed digs in restricted areas and/or multiple simultaneously (race condition?)
I can't see how that could happens.
finishDigging
is only called by the waitTimeout timeout, that timeout is started in the beginning of bot.dig
at a place where bot.targetDigBlock is certainly not-null (just after block.position is called).
Before setting bot.targetDigBlock to null the timeout is always cancelled.
Not sure what I'm missing. Some weird behavior of js ?
I am having the same issue, it says cannot read property position of null (digging.js). I am using the pathfinder plugin but it digs and then crashes.
/run/media/theoparis/TheoData/Essentials/Projects/Programming/untitled/node_modules/.pnpm/mineflayer@2.37.1/node_modules/mineflayer/lib/plugins/digging.js:41
location: bot.targetDigBlock.position,
^
TypeError: Cannot read property 'position' of null
It also seems to happen after it dies.
Oh, this was the issue that I was seeing when I was having what I thought was the callback issue mentioned in #1492. Apparently, it was this, not the callback.
Forgive me if I'm wrong - I've never contributed before, but would it be a bad idea to just try, except then pass this?
@UhMarco Probably not try-except here, but try to handle in a more graceful way. Find out what's causing it and try to avoid that situation entirely. If it's caused by dying or teleporting while mining, then those events should properly cancel active tasks properly.
I have seen this issue a significant number of times in the past week from new users in the Discord. I suspect a regression bug?
What is "this issue" exactly ? From above messages there are no clear error messages, no code and no context.
I think we should close this and re-open better issues
The only thing we can do here is add that null check so errors would be more explicit
@rom1504 The error code is:
...\node_modules\mineflayer\lib\plugins\digging.js:76
location: bot.targetDigBlock.position,
^
TypeError: Cannot read property 'position' of null
at finishDigging [as _onTimeout] (...\node_modules\mineflayer\lib\plugins\digging.js:76:39)
at Timer.listOnTimeout (timers.js:110:15)
This error seems to be thrown at random under seemingly unknown circumstances while the bot attempts to break a block. Usually by the pathfinder plugin or the collect block plugin. It's most likely triggered when the bot dies/teleports while in the middle of digging or tries to break a block and the server rejects it for some reason. (Ghost blocks?)
We can reopen the issue with a cleaner context if you'd like, but it's not known what code causes it. It a seemly random effect, but suddenly very common.
We can first add more null checks in that code and emit errors if the null cannot be handled at this point. It should clarify things
On Tue, Dec 22, 2020, 12:23 TheDudeFromCI notifications@github.com wrote:
@rom1504 https://github.com/rom1504 The error code is:
...\node_modules\mineflayer\lib\plugins\digging.js:76 location: bot.targetDigBlock.position, ^ TypeError: Cannot read property 'position' of null at finishDigging [as _onTimeout] (...\node_modules\mineflayer\lib\plugins\digging.js:76:39) at Timer.listOnTimeout (timers.js:110:15)
This error seems to be thrown at random under seemingly unknown circumstances while the bot attempts to break a block. Usually by the pathfinder plugin or the collect block plugin. It's most likely triggered when the bot dies/teleports while in the middle of digging or tries to break a block and the server rejects it for some reason. (Ghost blocks?)
We can reopen the issue with a cleaner context if you'd like, but it's not known what code causes it. It a seemly random effect, but suddenly very common.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer/issues/305#issuecomment-749492217, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437TLUJCRKZCZQYXE7RTSWB6SHANCNFSM4BKZOWAQ .
I get this unhandled error at random: