-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task to AsyncResult transition wraps Exception
into the AggregateException
#154
Comments
I don't think this is a problem with FsToolkit as this is how exceptions are thrown with Tasks via .NET https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/exception-handling-task-parallel-library |
Is it how |
It does not happen with |
Ah, this is the issue fsharp/fslang-suggestions#840 |
As long as it is a FSharp.Core issue I propose to use a corrected way of awaiting tasks |
Hey @NinoFloris see any downsides to doing this? |
I have this helper in various code-bases: let rec unpackException (exn : Exception) =
match exn with
| :? AggregateException as agg ->
match Seq.tryExactlyOne agg.InnerExceptions with
| Some x -> unpackException x
| None -> exn
| _ -> exn |
Note the edition therein in being synced with the canonical one in jet/FsKafka#92 (similarly fsprojects/FSharp.AWS.DynamoDB#49) The key specific diff in there is that cancellation will be guaranteed yield an exception, but the more important effect is that people debugging systems can do that based on being able to assume-but-verify identical behavior vs the needless variation having slight variations can cause (especially if we do manage to converge in the end). |
@TheAngryByrd please excuse the atting.... what would you say about a breaking change regarding this?
I guess the simplest thing is to remove implicit awaiting? (Checking if there's any way I can inhibit this as a consumer without changing the lib...) |
I did create an “asyncEx” in IcedTasks with the unwrapping aggregate semantics. Could you give that a once over and make sure it’s working the way you think it should be? If it does then I think it might be worth making another CE that can polyfill the current one. Breaking API changes are less scary usually because there’s obvious compile errors but runtime changes does kind of scare me. |
Oh yeah, I remember that now 🤦 |
Added a comment https://github.com/TheAngryByrd/IcedTasks/pull/24/files#r1556182882 TL;DR I don't think any deviations whatsoever from I don't understand enough about what forces Overall it boils down to two concerns:
For me, there can only be implicit behavior if there's a canonical expectation and/or spec for it. The canonical impl and the associated test snippets on fsssnip provide specific behavior under cancellation too, and that's pretty critical for me I guess this tells us we need to get this resolved in core because having TaskSeq, IcedTasks and/or here all have stuff that's not (Ironically, for my work project, having FsToolkit host AwaitTaskCorrect would be the perfect solution, but obviously having the world take a dependency on this entire lib for a correct awaittask impl is a step too far....) |
I think my conclusion/proposal is thus that the thing I'd do is remove the pieces that are bracketed with FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/AsyncResultCE.fs Lines 201 to 217 in dccdbbc
FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/AsyncResultCE.fs Lines 135 to 142 in dccdbbc
Luckily I'm not the maintainer of the library though, as I'd anticipate people immediately asking me: OK, so where it this wonderful There's also the question of what to replace the usage of FsToolkit.ErrorHandling/src/FsToolkit.ErrorHandling/AsyncResultCE.fs Lines 57 to 93 in dccdbbc
On the other hand, having a free-standing And then it begins... you add an |
Describe the bug
Matching by the
MsalClientException
does not happen as it is wrapped by theAggregateException
.To Reproduce
Steps to reproduce the behavior:
return!
in anasyncResult
CEAggregateException
.Expected behavior
A clear and concise description of what you expected to happen.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: