JakeStanger / mpd-discord-rpc

Rust application which displays your currently playing song / album / artist from MPD in Discord using Rich Presence.
https://crates.io/crates/mpd-discord-rpc
MIT License
92 stars 18 forks source link

Crashes if connection to Discord is lost #10

Closed JakeStanger closed 1 year ago

JakeStanger commented 4 years ago

If Discord restarts or the connection to its RPC server drops for whatever reason, the program crashes.

thread '<unnamed>' panicked at 'Failed to send outgoing data: IoError(Os { code: 32, kind: BrokenPipe, message: "Broken pipe" })', /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/discord-rpc-client-0.3.0/src/connection/manager.rs:131:30
emersonrp commented 1 year ago

My Discord crashes every time I sleep/wake the computer, and occasionally for no good reason whatsoever, so I run into this a lot.

JakeStanger commented 1 year ago

It looks like the underlying discord-presence crate doesn't surface the connection errors very well, so I'll open an issue there.

EDIT: Issue here: https://github.com/jewlexx/discord-presence/issues/62

JakeStanger commented 1 year ago

The above has been fixed and the library updated, so this is now resolved on master here.

I have noticed however that the connection retry logic in the library currently has no chill and really spams the socket/log, so I'm waiting for https://github.com/jewlexx/discord-presence/pull/73 to be merged before getting a release out or closing this.

emersonrp commented 1 year ago

I've managed to fix my Discord crashing on sleep/wake, which is itself a huge win, but yeah at boot time I think the systemd service starts before Discord so needs to be restarted every boot. All that to say that this is less of a worry than it used to be but still happens, and I'm super pleased to hear there are fixes in the works. Thanks!

ashprice commented 1 year ago

I do not get crashes, and I can restart discord fine, but the mentioned logging issue is causing a rather high rate of I/O on an SSD with BTRFS.

My journalctl -b log file for the last 6 hours - of a mostly idle machine - is 1.1GB in size, 5,383,274 lines long, with 5,375,627 occurrences of the words 'discord' and 'rpc.' I looked into it because I happened to be investigating I/O for other reasons. I'm not quite sure this even with the write amplification of BTRFS this can explain an unaccounted for 12.6GB+ of writes, but I suppose I will test presently...

JakeStanger commented 1 year ago

It will retry and log as fast as your hardware can handle at the moment, so it will add up very quickly.

Supposedly everything is in place in the discord library, so I'm hoping to get time this weekend to have another look and get it sorted.

JakeStanger commented 1 year ago

This is now fully resolved in the latest master.

I'm waiting on discord-presence to get a release out before I do the same, as this relies on the package's master branch currently.