Skip to content

Commit

Permalink
Merge pull request #1951 from TimWSpence/fix-future-leak
Browse files Browse the repository at this point in the history
Fix future leak
  • Loading branch information
jatcwang authored Nov 17, 2023
2 parents 323b62e + 4da3051 commit dc960d9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/free/src/main/scala/doobie/WeakAsync.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dc960d9

Please sign in to comment.