PrismarineJS / mineflayer

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

Long strings crashes bot. #1748

Closed tijm-wolters closed 3 years ago

tijm-wolters commented 3 years ago

Versions

Detailed description of a problem

When receiving a chat event with Mineflayer on 1.12.2 around 390 characters it dies. If I have a message containing around 390 or more characters and then another message following soon after the first message will fully log instantly, but the message after that has a large delay and at some point, if there are too many characters causing too much delay it will log out of the server without any error not taking any other commands. What I can see from looking at the server console is that the bot Timed out.

What did you try yet?

Firstly I tried logging it onto Hypixel doing '/g list' and seeing if it works, that didn't then I tried without any regex to see if that was the issue, it wasn't. Then I went and tested locally to find there is a soft limit of 390 characters in one line of chat, around that number it slowly dies, and at some point crashes my Mineflayer

Expected behavior

To print the big string, then the following string.

Actual behavior

It prints the big string (around 390 chars) then takes long then prints the following string then crashes. OR if it's even larger than that don't print the following string, wait for around 30 seconds then it crashes and logs out.

rom1504 commented 3 years ago

can you provide an example of code? this seems very surprising

tijm-wolters commented 3 years ago

Yes, of course, the location where we had the issue was in a large bot so I wanted to see if I could recreate it using just the examples of your tutorial(s)

require('dotenv/config')
require('./.env')
const mineflayer = require('mineflayer')

const bot = mineflayer.createBot({
    host: 'localhost', // Same issues on hypixel
    port: 25565,
    version: '1.12.2',
    username: process.env.EMAIL,
    password: process.env.PASSWORD
})

bot.on('message', (message) => {
    message = message.toString().replace(/[ࠀ]/g, '') // Also works without regex, this if for my own readability believe me I've checked
    console.log(message)
})

This was all I needed for it to break. My message is about 390 characters with 40+ words, something regular on Hypixel when doing /g list (Which is what I want to do)

Zn10plays commented 3 years ago

Tested on paper 1.12.2 without any issues well over 800 characters.

Is this still an issue?

tijm-wolters commented 3 years ago

I'm definitely still having the issue, maybe a combination of word count and characters that break it? I'm unsure

u9g commented 3 years ago

duplicate of https://github.com/PrismarineJS/mineflayer/issues/902