-
Notifications
You must be signed in to change notification settings - Fork 348
Fix silent hang in message processing loop when deserialization fails #15578
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -291,6 +291,18 @@ private void ProcessRequests(ITestRequestManager testRequestManager) | |
| catch (Exception ex) | ||
| { | ||
| EqtTrace.Error("DesignModeClient: Error processing request: {0}", ex); | ||
|
|
||
| // Notify the caller (IDE) about the error so it does not hang | ||
| // waiting for a response that will never come. | ||
| try | ||
| { | ||
| _communicationManager.SendMessage(MessageType.ProtocolError, ex.Message); | ||
| } | ||
| catch (Exception sendEx) | ||
| { | ||
| EqtTrace.Error("DesignModeClient: Failed to send ProtocolError to client: {0}", sendEx); | ||
| } | ||
|
Comment on lines
+295
to
+304
|
||
|
|
||
| Stop(); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -323,6 +323,32 @@ public bool AttachDebuggerToProcess(AttachDebuggerInfo attachDebuggerInfo) | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public void OnMessageReceived(object? sender, MessageReceivedEventArgs messageReceivedArgs) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| try | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| OnMessageReceivedCore(messageReceivedArgs); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| catch (Exception ex) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| EqtTrace.Error("TestRequestHandler.OnMessageReceived: Failed to process message, sending ProtocolError and closing session: {0}", ex); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // Notify the caller about the error so it does not hang | ||||||||||||||||||||||||||||||
| // waiting for a response that will never come. | ||||||||||||||||||||||||||||||
| try | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| SendData(_dataSerializer.SerializePayload(MessageType.ProtocolError, ex.Message)); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| catch (Exception sendEx) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| EqtTrace.Error("TestRequestHandler.OnMessageReceived: Failed to send ProtocolError: {0}", sendEx); | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| EqtTrace.Error("TestRequestHandler.OnMessageReceived: Failed to send ProtocolError: {0}", sendEx); | |
| EqtTrace.Error("TestRequestHandler.OnMessageReceived: Failed to send ProtocolError using serializer: {0}", sendEx); | |
| // Fallback: attempt to send a minimal, serializer-independent error message | |
| try | |
| { | |
| var fallbackMessage = "ProtocolError: " + ex.ToString(); | |
| EqtTrace.Verbose("TestRequestHandler.OnMessageReceived: Sending fallback ProtocolError message without serializer: {0}", fallbackMessage); | |
| SendData(fallbackMessage); | |
| } | |
| catch (Exception fallbackEx) | |
| { | |
| EqtTrace.Error("TestRequestHandler.OnMessageReceived: Failed to send fallback ProtocolError message: {0}", fallbackEx); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
ex.Messagealone can be empty and loses the exception type/context, which makes theProtocolErrorless actionable for the IDE/user. Consider including at least the exception type + message (e.g.,${ex.GetType().FullName}: ${ex.Message}) or a structured error payload, while being mindful of not sending overly large data (stack traces) over the protocol unless explicitly desired.