fix(transport): store expect errorDetails as serializable string - #3344
Merged
Dmitry Gozman (dgozman) merged 3 commits intoAug 12, 2026
Merged
Conversation
.NET Framework Exception.Data rejects non-serializable JsonElement values. Storing expect ErrorDetails as raw JSON text prevents orphaned assertion callbacks and keeps the driver connection alive after failing Expect(). Fixes microsoft#3342 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Dmitry Gozman (dgozman)
left a comment
Collaborator
There was a problem hiding this comment.
Hi Darío!
Thank you for the PR. I think the string serialization is the right solution, but I have some comments about the rest.
Thank you!
| } | ||
| catch | ||
| { | ||
| // Best-effort enrichment only; completing the callback is mandatory. |
Collaborator
There was a problem hiding this comment.
Let's not do this, or we won't be able to catch issues like this one. The earlier we know something went wrong, the better the chances for a fix.
Contributor
Author
There was a problem hiding this comment.
Done!
| /// On .NET Framework, Exception.Data rejects non-serializable values (e.g. JsonElement), | ||
| /// which used to orphan the callback and kill the driver connection (issue #3342). | ||
| /// </summary> | ||
| public class ConnectionTests |
Collaborator
There was a problem hiding this comment.
Let's drop this test, I don't like that we mostly test the test code itself. Ideally, we would get some .net framework coverage, but I'm not it's worth it at this point.
Contributor
Author
There was a problem hiding this comment.
Makes sense!
Keep serializable ErrorDetails string storage only. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Dmitry Gozman (dgozman)
approved these changes
Aug 12, 2026
Dmitry Gozman (dgozman)
left a comment
Collaborator
There was a problem hiding this comment.
Looks great, thank you!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Expect()hung forever and permanently killed the shared driver connection.Connection.Dispatchnow stores expecterrorDetailsas raw JSON text (serializable) instead ofJsonElement, and always completes the callback even if exception enrichment fails.Frame.ExpectAsyncparses that JSON string when buildingFrameExpectResult.Fixes #3342
Root cause
On .NET Framework,
Exception.Datarejects non-serializable values. StoringJsonElementthrew after the callback was already removed from_callbacks, soTrySetExceptionnever ran (orphaned hang) and the transport loop closed the connection.Test plan
ConnectionTests.Dispatch_ExpectErrorDetails_MustBeSerializableForExceptionData(portable unit test; fails on main when ErrorDetails isJsonElement)net8.0)LocatorAssertionsTests.ShouldSupportToBeCheckedandShouldSupportToHaveCount