Skip to content

Commit

Permalink
fix(bonfire): ignore all Redis errors but Canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
insertish committed Jun 20, 2024
1 parent 090d8cb commit 93e05e9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions crates/bonfire/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{collections::HashSet, net::SocketAddr, sync::Arc};
use async_tungstenite::WebSocketStream;
use authifier::AuthifierEvent;
use fred::{
error::{RedisError, RedisErrorKind},
interfaces::{ClientLike, EventInterface, PubsubInterface},
types::RedisConfig,
};
Expand Down Expand Up @@ -229,11 +230,14 @@ async fn listener(
// Handle Redis connection dropping
let (clean_up_s, clean_up_r) = async_channel::bounded(1);
let clean_up_s = Arc::new(Mutex::new(clean_up_s));
subscriber.on_error(move |_| {
let clean_up_s = clean_up_s.clone();
spawn(async move {
clean_up_s.lock().await.send(()).await.ok();
});
subscriber.on_error(move |err| {
if let RedisErrorKind::Canceled = err.kind() {
let clean_up_s = clean_up_s.clone();
spawn(async move {
clean_up_s.lock().await.send(()).await.ok();
});
}

Ok(())
});

Expand Down

0 comments on commit 93e05e9

Please sign in to comment.