-
Notifications
You must be signed in to change notification settings - Fork 258
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
API can deadlock when called from synchronous code. Should be using ConfigureAwait(false). #7192
Comments
A quick search reveals that PackageSearchResourceV3 does not use |
On a personal note, I think all of NuGet's code under However, these assemblies also run in Visual Studio, which has its own "set of rules". In particular, it uses a special threading library that has something called a After talking to the vs-threading experts within Microsoft a few months ago, the general recommendation we got was: code that never needs the UI thread can use The problem is that the authentication flow in Visual Studio starts off with a button click or some other action in VS's UI, goes through various NuGet dlls, including NuGet.Protocol.dll, and if the HTTP response comes back with a HTTP unauthorized status, it calls There's already an issue regarding changing NuGet to not prompt automatically for credentials. If this is implemented, then perhaps we'll be theoretically safe to use Alternatively perhaps someone could investigate if there's any other way to mitigate when a VS component has a synchronous method running on the UI thread, calls into NuGet, which causes an unauthorized HTTP response, which needs to show the credential login UI, if NuGet was to use Customers, such as yourselves, who use NuGet's SDK in your own apps, can either start using Microsoft.VisualStudio.Threading and As I wrote in the first paragraph, I think it would be great for us to use |
Details about Problem
The nuget v3 API uses async/await extensively, but doesn't seem to use ConfigureAwait(false) internally. This means synchronous APIs have to go out of their way to avoid deadlocks by calling your code on the threadpool, like this:
It would be super cool if you could add some .ConfigureAwait(false) calls wherever await is used. I don't believe there are any drawbacks.
The text was updated successfully, but these errors were encountered: