diff --git a/sqlx-core/src/pool/connection.rs b/sqlx-core/src/pool/connection.rs index a462a3ddac..1b68b76757 100644 --- a/sqlx-core/src/pool/connection.rs +++ b/sqlx-core/src/pool/connection.rs @@ -12,8 +12,10 @@ use crate::error::Error; use super::inner::{is_beyond_max_lifetime, PoolInner}; use crate::pool::connect::{ConnectPermit, ConnectionId}; use crate::pool::options::PoolConnectionMetadata; +use crate::rt; use std::future::Future; +const RETURN_TO_POOL_TIMEOUT: Duration = Duration::from_secs(5); const CLOSE_ON_DROP_TIMEOUT: Duration = Duration::from_secs(5); /// A connection managed by a [`Pool`][crate::pool::Pool]. @@ -149,7 +151,9 @@ impl PoolConnection { async move { let returned_to_pool = if let Some(floating) = floating { - floating.return_to_pool().await + rt::timeout(RETURN_TO_POOL_TIMEOUT, floating.return_to_pool()) + .await + .unwrap_or(false) } else { false };