Commit 1d3ebb8
Sync AddIncomingMessageFilter_Intercepts_Request_Messages on initialized notification
The test asserts strict counts for both requests and notifications observed by
the incoming message filter, but ListToolsAsync only synchronizes on the
request/response exchanges (initialize, tools/list). The notifications/initialized
message in between is fire-and-forget on the client, and the server dispatches
each incoming message via McpSessionHandler.ProcessMessageAsync as a
fire-and-forget Task with a forced thread-pool yield. So the assertion can run
before the notification has even reached the filter pipeline, surfacing as
''Expected: 1, Actual: 0'' for the notification count.
Observed on Ubuntu/Release/net9.0 CI; reproduces under load on any target.
Apply the same TaskCompletionSource pattern already used by the immediately
following AddIncomingMessageFilter_Multiple_Filters_Execute_In_Order test:
set a TCS inside the filter when the InitializedNotification is observed,
and await it before snapshotting the counts.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 8ba52bf commit 1d3ebb8
1 file changed
Lines changed: 15 additions & 0 deletions
File tree
- tests/ModelContextProtocol.Tests/Configuration
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
75 | 81 | | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
81 | 92 | | |
82 | 93 | | |
83 | 94 | | |
| |||
87 | 98 | | |
88 | 99 | | |
89 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
90 | 105 | | |
91 | 106 | | |
92 | 107 | | |
| |||
0 commit comments