Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2ef3b8a-d96c-4821-b346-694f49854981
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused test-only change correctly eliminates the identified enumeration race.
Review effort: Balanced
Findings: None
What changed in this PR
Deflakes the .NET session-event E2E test by making asynchronous event capture thread-safe.
Changes:
- Replaces
List<SessionEvent>withConcurrentQueue<SessionEvent>. - Uses
Enqueuefor concurrent callback writes.
| File | Description |
|---|---|
dotnet/test/E2E/SessionE2ETests.cs |
Prevents concurrent modification during startup-event assertions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
SDK Consistency ReviewThis PR ( Assessment: No cross-SDK consistency concerns.
No action needed for other SDKs.
|
Problem
The runtime repository's SDK compatibility run
35719029303failedSessionE2ETests.Should_Receive_Session_Eventson Alpine with:System.InvalidOperationException: Collection was modified; enumeration operation may not execute.The test records startup events in a mutable
List<SessionEvent>from an asynchronous event callback, then enumerates that list after observingsession.start. Later event delivery can mutate the list during the assertion. The test is worthwhile because it verifies that events emitted during session creation are not dropped.Changes
Use
ConcurrentQueue<SessionEvent>for the startup-event capture. This preserves the assertion while making concurrent callback writes and test enumeration safe.Product impact
No SDK product behavior changes. This only removes a race from the .NET E2E test.
Validation
github/copilot-agent-runtimerun35719029303, Alpine .NET in-process CAPI leg.git diff --check2390cf6681e3e24b289d6ee72fa729b664c944bb)