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

Bot completely freezes on chat message #902

Open
UltimateGG opened this issue Jan 25, 2020 · 9 comments
Open

Bot completely freezes on chat message #902

UltimateGG opened this issue Jan 25, 2020 · 9 comments
Labels
bug Stage3 idea is precisely specified, only coding is left to do

Comments

@UltimateGG
Copy link

UltimateGG commented Jan 25, 2020

Versions

  • mineflayer: 2.9.6

  • server: paperSpigot 1.8.8

  • node: 12.14.0

    I came across this chat message (Im not sure what about it) but it completely hangs the entire nodejs app, and I have to restart it. This could be with minecraft protocol or chat messages with that, but im not sure.

    Since im not sure what about it hangs the bot, its on the server manacube.net, on /server factions
    and the command "/f who royal"

    It seems to work with any other faction on there. I do nothing with the output, it just runs the command and then the process stops. It could be too big of a message possibly? I do need a fix for this in that case or at least to return an error.

Message:

____________________.[ Royal ].______________________
Description: Apply here! ---> https://discord.gg/xxxxxxx
Joining: invitation is required    
Land / Power / Maxpower:  1774/2500/2500
Founded: 12/1/19 1:34PM
Land value: no value no refund
Balance: no balance
Bans: 22
Allies(1/1):  §fkinkers
Online: (15/48): **§6[§4§lSrMod§6]§7[§d§lMadre§7]§c freshdougie, *§7[§c§lMOD§7][§d§lJOE-MAMA§7]§c§l XFactum, *§d§lSrDAD Harryyysan, +§7[§2§lM§7]§7[§b§lGLIZZYS§c§lDAD§7]§a Godly_op, +§7[§2§lM§7]§7[§c§lMASTER§e§lCARD§7]§a glizzygreg, +§7[§6§lBOT§7]§6§l RoyalFactions, +igotbannedincsgo Aucxi, +nocheatpls, +§7[§2§lM§7]§d§o[§6§oUr§e§oFav§d§o]§a iansanity, +§cA§eGreat§bGuy§a skillable, +§7[§2§lM§7][§dPlastered§7]§a DrVexyDankHarry, +legend Totemfire3, +OVERLORDSUPREMELEADER LIL_DUDI_21, +§f§oThe§e§oPack§b§oMaster§a Xinide, +§7[§2§lM§7]§a BranchingALT
Offline: (33/48): ***§7[§5§lMASTER§7]§d IamVexy, **HeadassOnBreak JustSoDank, *§7[§c§lMOD§7]§7[§8§lOnBreak§7]§c§l Jushua, *§7[§l§4MOD§7]§c _We_The_South_, *§6[§4§lMOD§6]§a[§b§lHayleysDaddy§a] Harry_s_Truman1, *[§aM§a] BestDiamondSword, *§3§lprincessboomer rangedhealer77, *§7[§c§lMod§7][§3Spa§bce§eCad§fet§7]§c dotEXP, +NojoGabe, +LoveHate, +§7[§2§lM§7][§cS§6t§ea§fr§7]§a QuasarsInSpace, +§7[§2§lM§7]§7[§fI§4Own§fFour§1Cars§7]§a lattas01, +§7[§2§lM§7]§a RECREATOR, +§7[§2§lM§7]§7[§bBOT§7]§a gpisstevie, +§7[§2§lM§7][§d§oSoft§e§oLemon§7]§a melseuss, +§7[§2§lM§7]§a _StreetFighter, +Aidan3521, +§5ARNEOZ Derpylatios, +JustSoAdam, +§7[§2§lM§7]§a MadPeppermint, +OdinsUlfhedinn, +§7[§2§lA§7]§a RH77, +§7[§2§lM§7]§7[§c§le§5§lThot§b§lbbg§7]§a xoabbie, +§7[§2§lM§7][§bCole§fWorld§7]§a coli0, +§7[§2§lM§7]§7[§e§lV§b§lisa§7]§7[§6SugarDaddy§7]§a tustificatethe3, +§7[§2§lM§7]§a _C4OnYourDoor_, +cooltitle WalkingBillboard, +§7[§2§lM§7]§7[§e§lHOPE§7]§a KorkadBanan, +§7[§2§lM§7][§c§l;3§7]§5§o[§6§o6§e§oCPS§5§o]§a Mushey, +§7[§2§lM§7]§6[§bMogz§6]§a Morgansoley, +§d§l§oM§b§o§lunchinq§a BestDiamondAxe, +§7[§2§lM§7]§7[§5§lCu§d§ltie§7]§a Mizuki_Okami_, +BiggestClownInRoyal prettyyodd
@UltimateGG
Copy link
Author

UltimateGG commented Jan 25, 2020

Ah so apparently removing the checkForChatPatterns function fixes this, but the problem is I need that to check for certain messages.

Ok I just added a if statement to check if it at least includes some of the patterns I would want, not fully a solution but fixes this for me.

@wvffle
Copy link
Member

wvffle commented Jan 25, 2020

Well this is a bug. Seems like regexp dos.

@wvffle wvffle added bug and removed possible bug labels Jan 25, 2020
@wvffle wvffle reopened this Jan 25, 2020
@wvffle
Copy link
Member

wvffle commented Jan 27, 2020

@gamer745 Can you run your bot with DEBUG="minecraft-protocol" and show me the output after typing /f who royal to the chat?

@extremeheat
Copy link
Member

This appears to be due to

const USERNAME_REGEX = '(?:\\(.+\\)|\\[.+\\]|.)*?(\\w+)'

the username detection regex looks unnecessarily complex.

@wvffle
Copy link
Member

wvffle commented Jan 18, 2021

@extremeheat actually, there's a reason to that. We're matching many possible chat patterns at once.
Though I guess it could be replaced with (?:\\([^)]+\\)|\\[.[^\]]+\\]|.)*?(\\w+) to be more strict.

@rom1504
Copy link
Member

rom1504 commented Jan 18, 2021 via email

@rom1504 rom1504 added the Stage3 idea is precisely specified, only coding is left to do label Feb 6, 2021
@banimania
Copy link

Is there any way to fix this?

@xanning
Copy link

xanning commented Jan 9, 2024

Can confirm, still happens. Bot goes and crashes randomly (probably a unsupported string) process hangs forever, and it just doesnt respond anymore.

@extremeheat
Copy link
Member

This lag should have been fixed in #2350

Not a great regex but not really relevant anymore in 1.19+ since chat is now formatted on the client. We don't need regex anymore. Kind of surprised chat event wasn't updated in 1.19 update, but should be an easy fix to listen to message and re-emit a chat or whisper:

// 1.19 changes the chat format to move <sender> prefix from message contents to a seperate field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Stage3 idea is precisely specified, only coding is left to do
Projects
None yet
Development

No branches or pull requests

6 participants