kazu-yamamoto / http2

HTTP/2.0 library including HPACK
BSD 3-Clause "New" or "Revised" License
84 stars 22 forks source link

Avoid `undefined` in client #146

Open FinleyMcIlwaine opened 3 weeks ago

FinleyMcIlwaine commented 3 weeks ago

Instead of raceing the background threads and the client, we run them concurrently and check which finishes first. If the background threads finished first, we wait for the client. If the client finished first, we cancel the background threads and return.

@kazu-yamamoto we also added a case in sendGoAway in Network.HTTP2.H2.Receiver so that GoAwayIsSent is handled the same as ConnectionIsClosed, which appears to more closely match the behavior of the frame sender. Also, previously if GoAwayIsSent happened, it would be wrapped in a BadThingHappen which would cause the frame sender to rethrow it. Does this change seem acceptable to you?

Also, this does not communicate the stream id from a GOAWAY to the client if the background threads finish first, but feel free to extend this PR to add that!

FinleyMcIlwaine commented 3 weeks ago

This solves #139, but uncovered some other uncaught exception output coming from tls in our stress tests of grapesy. That output was eliminated with this patch to tls https://github.com/haskell-tls/hs-tls/pull/477