Fix mis-reported cancellation of message transmission #492
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.
When a message is written to the output stream but not flushed, and then cancellation is requested, although the flush was canceled, the message was eventually going to be sent even though the client was no longer tracking it. This led to an unexpected response from the server to eventually be received and in v2.5,
JsonRpc
terminates the connection when the server sends an unexpected response to a request it doesn't remember sending.The fix is to stop honoring the
CancellationToken
after the message has been written. We still honor the disposal token during flush so as to not hold up shutdown, but after a message is written, we always wait for flush to complete if we're still running.Fixes #489