ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.26k stars 745 forks source link

Missing part of the response when using batched queries #7739

Open alex123098 opened 4 days ago

alex123098 commented 4 days ago

Product

Hot Chocolate

Version

14.1.0

Link to minimal reproduction

https://github.com/alex123098/hc-race-condition

Steps to reproduce

  1. Make sure you have curl installed
  2. Clone the repository
  3. Run the project using dotnet run
  4. Run the repro.sh script, which sends two queries batched into a single HTTP request
  5. Observe the output of the script

What is expected?

I expect one of 2 valid outputs:

---
Content-Type: application/json; charset=utf-8

{"requestIndex":1,"data":{"author":{"name":"Jon Skeet"}}}
---
Content-Type: application/json; charset=utf-8

{"requestIndex":0,"data":{"book":{"title":"C# in depth."}}}
-----

or

---
Content-Type: application/json; charset=utf-8

{"requestIndex":0,"data":{"book":{"title":"C# in depth."}}}
---
Content-Type: application/json; charset=utf-8

{"requestIndex":1,"data":{"author":{"name":"Jon Skeet"}}}
-----

What is actually happening?

4 times out of 5 the server returns results of only one query from the batch

Relevant log output

Additional context

I get the expected behavior if I remove calls to Task.Delay from both resolvers.

michaelstaib commented 2 days ago

This is the expected behavior... this is the new request batching protocol. Thats why it has a request index so that we can stream it down. This is part of the new composite schema specification effort we are doing together with Apollo, Netflix and The Guild.

michaelstaib commented 2 days ago

Ah ... what you are saying is that one output is missing? I will have a look at it.

michaelstaib commented 2 days ago

This is the expected behavior

was referring to the fact that it can be out of order.