diff --git a/Cargo.toml b/Cargo.toml index 403bc0ba..ce4d4e9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fred" -version = "6.2.1" +version = "6.2.2" authors = ["Alec Embke "] edition = "2021" description = "An async Redis client built on Tokio." diff --git a/src/protocol/connection.rs b/src/protocol/connection.rs index 146a00d0..fa517310 100644 --- a/src/protocol/connection.rs +++ b/src/protocol/connection.rs @@ -937,10 +937,20 @@ impl RedisWriter { /// /// Returns the in-flight commands that had not received a response. pub async fn graceful_close(mut self) -> CommandBuffer { - let _ = self.sink.close().await; - if let Some(mut reader) = self.reader { - let _ = reader.wait().await; - } + let timeout = globals().default_connection_timeout_ms(); + let _ = utils::apply_timeout( + async { + let _ = self.sink.close().await; + if let Some(mut reader) = self.reader { + let _ = reader.wait().await; + } + + Ok::<_, RedisError>(()) + }, + timeout, + ) + .await; + self.buffer.lock().drain(..).collect() } }