Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mis-reported cancellation of message transmission #498

Merged
merged 4 commits into from
Jul 16, 2020

Conversation

AArnott
Copy link
Member

@AArnott AArnott commented Jul 16, 2020

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

This was already merged to master via #492

AArnott added 2 commits July 15, 2020 14:41
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 microsoft#489
@AArnott AArnott added this to the v2.5 milestone Jul 16, 2020
@AArnott AArnott self-assigned this Jul 16, 2020
@codecov-commenter
Copy link

codecov-commenter commented Jul 16, 2020

Codecov Report

Merging #498 into v2.5 will decrease coverage by 0.01%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             v2.5     #498      +/-   ##
==========================================
- Coverage   90.64%   90.62%   -0.02%     
==========================================
  Files          50       50              
  Lines        3838     3841       +3     
==========================================
+ Hits         3479     3481       +2     
- Misses        359      360       +1     
Impacted Files Coverage Δ
src/StreamJsonRpc/MessageHandlerBase.cs 97.56% <50.00%> (-1.18%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 813fd29...b7fa4f7. Read the comment docs.

In case the thrown token isn't exactly the one we passed in, we still want to translate the OCE to an ODE if disposal is in progress.
@AArnott AArnott merged commit c55a636 into microsoft:v2.5 Jul 16, 2020
@AArnott AArnott deleted the fix489 branch July 16, 2020 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants