diff --git a/awc/CHANGES.md b/awc/CHANGES.md index a2e51c8d2..11cb150ab 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -2,6 +2,7 @@ ## Unreleased +- Prevent panics on connection pool drop when Tokio runtime is shutdown early. - Minimum supported Rust version (MSRV) is now 1.75. ## 3.5.1 diff --git a/awc/src/client/pool.rs b/awc/src/client/pool.rs index 1736f2b02..5d764f729 100644 --- a/awc/src/client/pool.rs +++ b/awc/src/client/pool.rs @@ -76,7 +76,9 @@ where fn close(&self, conn: ConnectionInnerType) { if let Some(timeout) = self.config.disconnect_timeout { if let ConnectionInnerType::H1(io) = conn { - actix_rt::spawn(CloseConnection::new(io, timeout)); + if tokio::runtime::Handle::try_current().is_ok() { + actix_rt::spawn(CloseConnection::new(io, timeout)); + } } } }