azalea-rs / azalea

A collection of Rust crates for making Minecraft bots, clients, and tools.
https://azalea.matdoes.dev
MIT License
361 stars 48 forks source link

bug: panicked at azalea-client/src/events.rs:164:47: #151

Closed 1zun4 closed 1 month ago

1zun4 commented 3 months ago

Hello,

https://github.com/azalea-rs/azalea/blob/main/azalea-client/src/events.rs is filled with .unwrap() instead of handling the error properly. And there is no way for me to handle any errors from outside.

2024-05-25T00:53:53.371715Z ERROR tokio-runtime-worker swarmcontrol: panicked at /home/izuna/.cargo/git/checkouts/azalea-2c9a2bd95159baf4/a70e0b6/azalea-client/src/events.rs:164:47:
called `Result::unwrap()` on an `Err` value: SendError { .. } panic.file="/home/izuna/.cargo/git/checkouts/azalea-2c9a2bd95159baf4/a70e0b6/azalea-client/src/events.rs" panic.line=164 panic.column=47

This problem occurs on join, which fails on the first tick. It should therefore throw a result immediately instead of causing tokio threads to panic.

Also not sure if it is really caused by azalea, but I keep growing in memory with every new time I join with a new client. I woke up to 64gb of memory filled up and 12 cores at 100% CPU utilization.

1zun4 commented 3 months ago

I think there should be a general handler that takes a bad result and safely stops the execution of ONE bot.

mat-1 commented 1 month ago

I've removed those unwraps in https://github.com/azalea-rs/azalea/commit/ca48ed9e2596e3ccfeb7d975e276a6168de74420 which should at least fix the panics so I'm going to close this issue now.