x/net/http2: Race in handler execution results in zero-byte data frame, causing incompatibility with gRPC #56317
What version of Go are you using (
The text was updated successfully, but these errors were encountered:
I did a bit more investigation into this issue, and found that the original RCA hypothesis is not entirely correct. This bug seems to be a side effect of
This results in the possibility that
The solution in my case is to simply omit
While the behavior is inconvenient, I think all components are WAI:
gRPC wants a response to either consist of either a HEADERS frame, DATA frames, and a final HEADERS frame with END_STREAM set; or just a HEADERS frame with END_STREAM set. (It calls this second case "trailers only", but from an HTTP/2 perspective this is headers only. There are no trailers.)
The Go HTTP/2 server will send initial HEADERS with no END_STREAM set if the headers are flushed before data is written.
The fix is to not set FlushInterval.
As @LINKIWI concludes, while this is an unfortunate interaction, everything is working properly: Flushing headers before the handler returns needs to send HEADERS with no END_STREAM (because the server doesn't yet know if data will be written to the stream), and setting a negative
Otherwise, I don't think there's anything that needs doing here.