-
-
Notifications
You must be signed in to change notification settings - Fork 922
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
Asynchronous task blocked on a synchronous call #3476
Comments
Newtonsoft.Json is a synchronous package and does not internally contain asynchronous serialization calls. So the easiest fix would be to use the System.Text.Json serializer which fully supports async reading and writing. You said you are using 'package version 3.4' -- are you referring to GraphQL.Server.Transports.AspNetCore version 3.4 ? That specifically uses version 2.3.0 of GraphQL.NET; the latest version of GraphQL.NET is 7.2.1. I do not believe the server project contains a compatible System.Text.Json serializer to use with that version. While of course I'd suggest moving to the latest version, even moving up one major version to GraphQL 3.x (with Server 4.x), you can utilize the System.Text.Json serializer. Note that the current version of GraphQL.NET with GraphQL.NET Server (7.2.1 and 7.2.0 respectively) supports hosting on top of either (a) ASP.NET Core 2.1, or (b) ASP.NET Core 3.1 through 7.0, for maximum compatibility. For ASP.NET Core 2.1, you may run on top of either .NET Framework or .NET Core 2.1. Migration notes for each new major version of GraphQL.NET are listed here:
We only have migration notes for the server project between version 6 and version 7: Note that the current version of GraphQL.NET does support the Newtonsoft.Json converter and it does still contain an |
Yes, I am using the graphql.server.transports.aspnetcore 3.4.0, thanks a lot for your valuable suggestions. if GraphQL.NET is still using the Newtonsoft.Json, so probably the issue would still be there as you mentioned, but I will upgrade to latest version of package. If I face this issue again with the latest version what would be your suggestion? |
Let's cross that bridge when we come to it. Again, I'd strongly recommend switching to the System.Text.Json serializer, so unless you have a particular need for Newtonsoft.Json, I would switch to using that regardless. |
Note that this PR contains a potential fix for the issue you mentioned: It would need to be revised for v7 |
We are currently on version 7.x. If you experience the issue on a current version, we may be able to help further. |
After upgrading to the latest package, we no longer encountered this issue. Thank you @Shane32 for guiding us. |
Description
Package version - 3.4
I getting the following two issues intermittently while the application startup...
2 threads are performing asynchronous work in method 'GraphQL.dll!GraphQL.Http.HttpResponseStreamWriter.FlushInternal(bool)', but are waiting on a synchronous call to method 'System.Private.CoreLib.dll!System.Threading.ManualResetEventSlim.Wait(int, System.Threading.CancellationToken)'. This may cause thread pool starvation and hangs.
10 threads are performing asynchronous work in method 'Newtonsoft.Json.dll!Newtonsoft.Json.JsonTextReader.ReadData(bool, int)', but are waiting on a synchronous call to method 'System.Private.CoreLib.dll!System.Threading.ManualResetEventSlim.Wait(int, System.Threading.CancellationToken)'. This may cause thread pool starvation and hangs.
Steps to reproduce
This issue is intermittent and occurs on Application start-up.
Expected result
What should happen?
Actual result
The application was not accepting any other requests as the thread was blocked
Environment
Windows 64
The text was updated successfully, but these errors were encountered: