Skip to content

Commit 5c8fe3e

Browse files
committed
always catch internal cancellations
1 parent 172dc31 commit 5c8fe3e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Compiler/Utilities/Cancellable.fs

+9-6
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ type CancellableBuilder() =
157157
match Cancellable.run ct comp with
158158
| ValueOrCancelled.Value res -> ValueOrCancelled.Value(Choice1Of2 res)
159159
| ValueOrCancelled.Cancelled exn -> ValueOrCancelled.Cancelled exn
160-
with err ->
161-
ValueOrCancelled.Value(Choice2Of2 err)
160+
with
161+
| :? OperationCanceledException as exn when ct.IsCancellationRequested -> ValueOrCancelled.Cancelled exn
162+
| err -> ValueOrCancelled.Value(Choice2Of2 err)
162163

163164
match compRes with
164165
| ValueOrCancelled.Value res ->
@@ -179,8 +180,9 @@ type CancellableBuilder() =
179180
match Cancellable.run ct body with
180181
| ValueOrCancelled.Value res -> ValueOrCancelled.Value(Choice1Of2 res)
181182
| ValueOrCancelled.Cancelled exn -> ValueOrCancelled.Cancelled exn
182-
with err ->
183-
ValueOrCancelled.Value(Choice2Of2 err)
183+
with
184+
| :? OperationCanceledException as exn when ct.IsCancellationRequested -> ValueOrCancelled.Cancelled exn
185+
| err -> ValueOrCancelled.Value(Choice2Of2 err)
184186

185187
match compRes with
186188
| ValueOrCancelled.Value res ->
@@ -201,8 +203,9 @@ type CancellableBuilder() =
201203
match Cancellable.run ct comp with
202204
| ValueOrCancelled.Value res -> ValueOrCancelled.Value(Choice1Of2 res)
203205
| ValueOrCancelled.Cancelled exn -> ValueOrCancelled.Cancelled exn
204-
with err ->
205-
ValueOrCancelled.Value(Choice2Of2 err)
206+
with
207+
| :? OperationCanceledException as exn when ct.IsCancellationRequested -> ValueOrCancelled.Cancelled exn
208+
| err -> ValueOrCancelled.Value(Choice2Of2 err)
206209

207210
match compRes with
208211
| ValueOrCancelled.Value res ->

0 commit comments

Comments
 (0)