PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.96k stars 904 forks source link

Unexpected "ERR_INVALID_ARG_TYPE" #2154

Closed Kistras closed 3 years ago

Kistras commented 3 years ago

Versions

Detailed description of a problem

I'm trying to use a modified echo example to join my server, but it seems that after some time it crashes. image

What did you try yet?

Launched this code without any events/hooks, still crashes npm i mineflayer, it was up to date.

Your current code

const mineflayer = require('mineflayer')
const bot = mineflayer.createBot({
  host: 'localhost',
  port: 55045,
  username: 'Biba'
})
bot.on('chat', (username, message) => {
  if (username === bot.username) return
  bot.chat(message)
})

Expected behavior

Bot joins the server freely and then echoes any messages I send to it.

What happened instead

Bot joins the server and immediately crashes.

Additional context

It seems that all this happened after 1.17 update. Worked well earlier. Sometimes I'm getting an error as specified here, but I forgot to screenshot it and now I'm not able to do so.

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at new NodeError (node:internal/errors:371:5)
    at Function.from (node:buffer:322:9)
    at ChunkColumn.loadParsedLight (C:\Users\Иван\node_modules\prismarine-chunk\src\pc\1.17\ChunkColumn.js:338:38)
    at Client.<anonymous> (C:\Users\Иван\node_modules\mineflayer\lib\plugins\blocks.js:311:14)
    at Client.emit (node:events:394:28)
    at FullPacketParser.<anonymous> (C:\Users\Иван\node_modules\minecraft-protocol\src\client.js:91:12)
    at FullPacketParser.emit (node:events:394:28)
    at addChunk (C:\Users\Иван\node_modules\readable-stream\lib\_stream_readable.js:298:12)
    at readableAddChunk (C:\Users\Иван\node_modules\readable-stream\lib\_stream_readable.js:280:11)
    at FullPacketParser.Readable.push (C:\Users\Иван\node_modules\readable-stream\lib\_stream_readable.js:241:10) {
  code: 'ERR_INVALID_ARG_TYPE'
}
nickelpro commented 3 years ago

Update pr-chunk, fixed in 1.26.0 of that package

Kistras commented 3 years ago

Update pr-chunk, fixed in 1.26.0 of that package

Used npm i prismarine-chunk@1.26.0, haven't crashed yet. Should prismarine-chat package be updated too as it makes this random fromNotch error? Thank you.

u9g commented 3 years ago

Update pr-chunk, fixed in 1.26.0 of that package

Used npm i prismarine-chunk@1.26.0, haven't crashed yet. Should prismarine-chat package be updated too as it makes this random fromNotch error? Thank you.

What error?