chore: Log errors from failed pub/sub messages

This commit is contained in:
Zomatree
2023-08-10 21:04:31 +01:00
committed by Paul Makles
parent bfdd713d38
commit 92032cd9bc
3 changed files with 11 additions and 5 deletions

View File

@@ -3,4 +3,4 @@ members = ["crates/delta", "crates/bonfire", "crates/quark", "crates/core/*"]
[patch.crates-io] [patch.crates-io]
# mobc-redis = { git = "https://github.com/insertish/mobc", rev = "8b880bb59f2ba80b4c7bc40c649c113d8857a186" } # mobc-redis = { git = "https://github.com/insertish/mobc", rev = "8b880bb59f2ba80b4c7bc40c649c113d8857a186" }
redis = { git = "https://github.com/insertish/redis-rs", rev = "1a41faf356fd21aebba71cea7eb7eb2653e5f0ef" } redis = { git = "https://github.com/revoltchat/redis-rs", rev = "cfd75cdebebf55f646697a933981741e74949c89" }

View File

@@ -33,3 +33,4 @@ async-std = { version = "1.8.0", features = [
# core # core
revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] } revolt-presence = { path = "../core/presence", features = ["redis-is-patched"] }
sentry = "0.31.5"

View File

@@ -136,13 +136,13 @@ pub fn spawn_client(db: &'static Database, stream: TcpStream, addr: SocketAddr)
);*/ );*/
// Handle incoming events. // Handle incoming events.
match conn.on_message().next().await.map(|item| { match conn.on_message().next().await.map(|res| {
( res.map(|item|(
item.get_channel_name().to_string(), item.get_channel_name().to_string(),
redis_kiss::decode_payload::<EventV1>(&item), redis_kiss::decode_payload::<EventV1>(&item),
) ))
}) { }) {
Some((channel, item)) => { Some(Ok((channel, item))) => {
if let Ok(mut event) = item { if let Ok(mut event) = item {
if state if state
.handle_incoming_event_v1( .handle_incoming_event_v1(
@@ -160,6 +160,11 @@ pub fn spawn_client(db: &'static Database, stream: TcpStream, addr: SocketAddr)
warn!("Failed to deserialise an event for {channel}!"); warn!("Failed to deserialise an event for {channel}!");
} }
} }
Some(Err(e)) => {
info!("Error while consuming pub/sub messages: {e:?}");
sentry::capture_error(&e);
break
}
// No more data, assume we disconnected or otherwise // No more data, assume we disconnected or otherwise
// something bad occurred, so disconnect user. // something bad occurred, so disconnect user.
None => break, None => break,