You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Repro:
Invoke a method on a server and then cancel the cancellation token passed to the method. Depending on your luck, the cancellation may happen so that the header is already written to the underlying stream here, but the content is not, and it got cancelled here. Sending another message on that JsonRPC makes it send the header and the content. The receiving end will get the header from the first (cancelled) message, and then the header and the content from the next message. It'll try to use the first header to read the whole message, and will read malformed json (it will contain the header and part of the body of the second message). Then it'll close the stream.
Expected:
Sending a JSON RPC message by the message handler should be atomic. We should write header and content together, or don't write anything at all.
The text was updated successfully, but these errors were encountered:
HeaderDelimitedMessageHandler accepts cancellation token from the call
to JsonRpc.InvokeAsync. If the caller cancels the token at the right
moment, it may happen when the header is already written to the stream,
but the message content is not. If this happens, on the next call the
reciever will get a malformed message - a header from the first message,
a header and content from the next message. This will cause JsonRpc to
error out, close the stream, and cancel the next method.
This fix makes sure that writing in HeaderDelimiteMessageHandler occurs
atomically and cannot be interrupted by cancelled cancellation token.
Fix for #55.
Repro:
Invoke a method on a server and then cancel the cancellation token passed to the method. Depending on your luck, the cancellation may happen so that the header is already written to the underlying stream here, but the content is not, and it got cancelled here. Sending another message on that JsonRPC makes it send the header and the content. The receiving end will get the header from the first (cancelled) message, and then the header and the content from the next message. It'll try to use the first header to read the whole message, and will read malformed json (it will contain the header and part of the body of the second message). Then it'll close the stream.
Expected:
Sending a JSON RPC message by the message handler should be atomic. We should write header and content together, or don't write anything at all.
The text was updated successfully, but these errors were encountered: