Deserialization errors are indistinguishable from connection loss - how to debug? #1302
-
Title: Deserialization errors are indistinguishable from connection loss - no way to debugBody:According to the disconnecting documentation, when "a message is received that does not parse to a valid JSON-RPC message", the connection is terminated and all outstanding requests are faulted with This makes it impossible to debug deserialization issues when using Reproduction
Current behavior
Expected behaviorEither:
ImpactThis makes it nearly impossible to use ExampleWorking with var formatter = new SystemTextJsonFormatter
{
JsonSerializerOptions = McpJsonUtilities.DefaultOptions
};
// Fails with ConnectionLostException, no idea whyIs there any way to see the actual deserialization error that causes the connection to be terminated? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
UPDATE - Workaround Found (Core Issue Remains)After hours of debugging, we found a workaround but the core issue of deserialization errors being indistinguishable from connection loss remains unresolved. What we discovered:
What we DIDN'T discover:
The core problem remains:When StreamJsonRpc encounters what it considers an invalid message, it still:
Workaround:If you're getting But this doesn't solve the fundamental issue that deserialization problems are completely opaque to developers. |
Beta Was this translation helpful? Give feedback.
Thanks for sharing.
Have you tried the troubleshooting doc? In particular, adding a
TraceSourcewith a listener to both sides? We tend to log quite a bit if you crank up verbosity, so I'd be surprised if what you need isn't there.