-
Notifications
You must be signed in to change notification settings - Fork 64
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
fix: Refactor to eliminate usage of .GetAwaiter().GetResult()
in Framework builds. (#2534)
#2535
Conversation
.GetAwaiter().GetResult()
in Framework builds. (#2534).GetAwaiter().GetResult()
in Framework builds. (#2534)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2535 +/- ##
==========================================
+ Coverage 80.47% 80.50% +0.02%
==========================================
Files 459 459
Lines 28775 28873 +98
Branches 3153 3167 +14
==========================================
+ Hits 23158 23244 +86
- Misses 4837 4843 +6
- Partials 780 786 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
|
{ | ||
return _httpContent.ReadAsStreamAsync(); | ||
return _httpContent.ReadAsStreamAsync().GetAwaiter().GetResult(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I ask you how these changes prevent potential deadlocks since I still see GetAwaiter().GetResult()
in many places?
Also I'm curious now when you replaced asynchronous calls by sync analogues how this affected performance (e,g. scalability) ?
I'm not familiar with the code base but maybe it was possible to use async natively all the way around?
Thanks
P.S.
I guess the PR description is a bit misleading
"With this change, there are now no usages of .GetAwaiter().GetResult() in code built for the .NET Framework target."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oleksandrk-adorama Thanks for your comment.
The code snippet you referenced above is only included in the .NET Standard 2.0 build of the agent (see line 4).
So while we do still have several usages of .GetAwaiter().GetResult()
, none of them occur in the .NET Framework build.
As for performance, there shouldn't be any impact, as the previous calls were synchronously waiting for the async method to finish and have been replaced with direct sync methods.
There are a few architectural concerns with the present implementation of the .NET agent that prevent us from using async everywhere; we're hoping to resolve those concerns in a future version of the agent but have no firm timeline for it at present.
Refactors
HttpCollectorWire.Send()
to remove usage of.GetAwaiter().GetResult()
, which required additional refactoring inIHttpClient
andIHttpContentWrapper
.With this change, there are now no usages of
.GetAwaiter().GetResult()
in code built for the .NET Framework target.Resolves #2534