Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected error #3244

Closed
1 task done
gabrielmar opened this issue Dec 15, 2023 · 2 comments
Closed
1 task done

Unexpected error #3244

gabrielmar opened this issue Dec 15, 2023 · 2 comments
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@gabrielmar
Copy link

  • The FAQ doesn't contain a resolution to my issue

Versions:

Problem:

Unexpected error crashes the application

Errors:

PartialReadError: Read error for undefined : Missing characters in string, found size is 24 expected size was 111
    at new ExtendableError (/node_modules/protodef/src/utils.js:63:13)
    at new PartialReadError (/node_modules/protodef/src/utils.js:70:5)
    at ProtoDef.readPString (/node_modules/protodef/src/datatypes/utils.js:109:11)
    at ProtoDef.read (/node_modules/protodef/src/protodef.js:36:25)
    at ProtoDef.read (/node_modules/protodef/src/protodef.js:36:25)
    at ProtoDef.read (/node_modules/protodef/src/protodef.js:114:29)
    at e.message (/node_modules/protodef/src/protodef.js:153:49)
    at tryCatch (/node_modules/protodef/src/utils.js:50:16)
    at ProtoDef.parsePacketBuffer (/node_modules/protodef/src/protodef.js:153:29)
    at Client.onCustomPayload (/node_modules/minecraft-protocol/src/client/pluginChannels.js:56:31) {
  partialReadError: true
}
RangeError [ERR_OUT_OF_RANGE]: The value of "sourceStart" is out of range. It must be >= 0 && <= 256. Received 8192
    at _copy (node:buffer:226:13)
    at Buffer.copy (node:buffer:816:12)
    at Chunk.load (/node_modules/prismarine-chunk/src/pc/1.8/chunk.js:205:31)
    at addColumn (/node_modules/mineflayer/lib/plugins/blocks.js:57:14)
    at Client.<anonymous> (/node_modules/mineflayer/lib/plugins/blocks.js:272:5)
    at Client.emit (node:events:514:28)
    at emitPacket (/node_modules/minecraft-protocol/src/client.js:83:12)
    at FullPacketParser.<anonymous> (/node_modules/minecraft-protocol/src/client.js:107:9)
    at FullPacketParser.emit (node:events:514:28)
    at addChunk (/node_modules/protodef/node_modules/readable-stream/lib/_stream_readable.js:279:12) {
  code: 'ERR_OUT_OF_RANGE'
}

Code

import mineflayer from 'mineflayer';

const bot = mineflayer.createBot({
  host: 'IP ADDRESS',
  username: Array.from({ length: 2 }, () => (Math.random() * 10).toString(36))
    .join('')
    .replace(/\W/g, '')
    .slice(0, 16),
  auth: 'offline',
  version: '1.8.9',
});

bot.on('entityUpdate', (entity) => {
  if (entity.type === 'object' && entity.name === 'ArmorStand') {
    const armor = entity.metadata
      .filter((meta) => typeof meta === 'string' && String(meta).includes(textToSearch))
      .map((meta) => String(meta).replace(/\D/g, ''))
      .join('');
    if (armor) {
      resolve(parseInt(armor));
      bot.end();
    }
  }
});

bot.on('kicked', () => {
  resolve(-1);
});

bot.on('end', () => {
  resolve(-1);
});

bot.on('error', () => {
  resolve(-1);
  bot.end();
});
@gabrielmar gabrielmar added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Dec 15, 2023
@extremeheat
Copy link
Member

There's no reason that should be crashing the bot. If the bot quits the server, that's because you explicitly instruct it to do so in this code on error. Serialization errors can be ignored, it could very well just be the server sending invalid data. The second error could also be an issue with prismarine-chunk's handling of 1.8 chunks if it's not the servers' fault, but that's not clear based on the data.

@gabrielmar
Copy link
Author

I did a try catch to avoid crashing my code, I don't know why this error occurred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

2 participants