File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
src/FSharpPlus/Extensions Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -315,18 +315,26 @@ module ValueTask =
315315 let mutable ran = false
316316 let compensation () =
317317 if not ran then
318- compensation ()
319318 ran <- true
319+ compensation ()
320320 try
321321 let task = body ()
322- if task.IsCompleted then compensation (); task
322+ if task.IsCompleted then
323+ try
324+ compensation ()
325+ task
326+ with e -> raise e
323327 else
324328 let tcs = TaskCompletionSource< 'T> ()
325329 let f = function
326- | Succeeded r -> tcs.SetResult r
327- | Faulted exn -> tcs.SetException exn.InnerExceptions
328- | Canceled -> tcs.SetCanceled ()
329- task.ConfigureAwait( false ) .GetAwaiter() .UnsafeOnCompleted ( fun () -> compensation (); f task)
330+ | Succeeded r -> tcs.SetResult r
331+ | Faulted aex -> tcs.SetException aex.InnerExceptions
332+ | Canceled -> tcs.SetCanceled ()
333+ task.ConfigureAwait( false ) .GetAwaiter() .UnsafeOnCompleted ( fun () ->
334+ try
335+ compensation ()
336+ f task
337+ with e -> tcs.SetException e)
330338 ValueTask< 'T> tcs.Task
331339 with _ ->
332340 compensation ()
You can’t perform that action at this time.
0 commit comments