Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This closes #76 .
@kazu-yamamoto , this is two commits.
RST_STREAM
). The diagram I add in this commit does not yet reflect the change I want to make, but rather the status quo prior to this PR.Closed
stream state, which is then applied inprocessState
; this matches what you do for all the other cases.As I was working on my own library, I noticed that there is a second important use case for this fix (the first being the one I outline in #76): it's not just important when the server wants to tell the client "don't send any more here, we're done", but also when the server wants to tell the client "this particular method is not actually supported at all, don't even start sending me anything". Not terribly relevant for you, except to let you know that I've tested both scenarios with the fix from this PR, and they are now both working correctly.
Related bug?
However, something that had me concerned as I was documenting the state transitions: except in the case of
RST_STREAM
, a stream is never really closed on the client side (as I mention below the diagram in the code, when thestreamState
IORef
is collected, it is typically inHalfClosedRemote
state). This doesn't matter by itself, but I started tracking when these are then GCed, and it appears that they are not GCed at all, until the entire connection to the server is closed.What I would have expected to see when I started documenting all the state transitions is that when the client sends their final message (meaning, the thread that gets spawned by
requestStreaming
terminates), the connection transitions toHalfClosedLocal
, at which point it can be closed entirely and forgotten about once the server closes their end too. What do you think? Should I try to submit a PR for that, also, or have I misunderstood what the intended control flow?(I can open a separate issue about this if that's better.)