From 4ca8a3b5ce482a30897c336c16b3d4302a87da1c Mon Sep 17 00:00:00 2001 From: Tim Spence Date: Fri, 10 Nov 2023 17:27:09 +0000 Subject: [PATCH] Fix potential future leak --- modules/free/src/main/scala/doobie/WeakAsync.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/free/src/main/scala/doobie/WeakAsync.scala b/modules/free/src/main/scala/doobie/WeakAsync.scala index 6bde8e087..54da38f6d 100644 --- a/modules/free/src/main/scala/doobie/WeakAsync.scala +++ b/modules/free/src/main/scala/doobie/WeakAsync.scala @@ -58,8 +58,10 @@ object WeakAsync { F.syncStep[G, T](fa, Int.MaxValue).flatMap { // MaxValue b/c we assume G will implement ceding/fairness case Left(fa) => G.fromFutureCancelable { - G.delay(dispatcher.unsafeToFutureCancelable(fa)).map { case (fut, cancel) => - (fut, G.fromFuture(G.delay(cancel()))) + G.uncancelable { _ => + G.delay(dispatcher.unsafeToFutureCancelable(fa)).map { case (fut, cancel) => + (fut, G.fromFuture(G.delay(cancel()))) + } } } case Right(a) => G.pure(a)