aatxe / irc

the irc crate – usable, async IRC for Rust
Mozilla Public License 2.0
527 stars 100 forks source link

irc 0.13.6 may panic on ping timeout #167

Closed kpcyrd closed 4 years ago

kpcyrd commented 5 years ago

I just noticed I still had a project running that was connected using the irc crate and apparently a thread panic'ed while switching networks during the day:

thread '<unnamed>' panicked at 'connection reset: no ping response', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/irc-0.13.6/src/client/mod.rs:707:41
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PingTimeout', libcore/result.rs:1009:5

The relevant code seems to be:

let outgoing_future = sink.send_all(rx_outgoing.map_err::<error::IrcError, _>(|_| {
    unreachable!("futures::sync::mpsc::Receiver should never return Err");
})).map(|_| ()).map_err(|e| panic!("{}", e));
aatxe commented 5 years ago

This is expected if you're using the old API (IrcClient::from_config and IrcClient::new). As far as I can tell, there's no obvious way to resolve this with that API setup, but if you use the IrcReactor API (or IrcClient::new_future) directly, as shown in the README, these errors should bubble out from IrcReactor::run and thus can be handled by user code.