csharp-sdk/tests/ModelContextProtocol.Tests
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Joel Forsyth 4d011995d1 Release SSE response stream reference when GET request ends
StreamableHttpServerTransport held a reference to the Kestrel SSE
response stream via _httpSseWriter for the entire session lifetime.
Since the transport is only disposed when the session itself is disposed
(via explicit DELETE or idle timeout), clients that disconnect without
sending DELETE — which is typical for long-lived SSE connections — left
the response stream pinned for the remainder of the idle timeout window.

Because the Kestrel HTTP connection (and its associated memory pool
buffers, Pipe readers/writers, socket send/receive buffers) is only
collectible once all references to the response stream are released,
this pinned ~20MiB of unmanaged memory per disconnected session until
cleanup. Under steady connect/disconnect churn (e.g., IDE availability
probes) this accumulated into sustained memory growth that eventually
OOMKilled the container.

Fix: release _httpSseWriter from within HandleGetRequestAsync's finally
block so the reference is dropped as soon as the GET request exits, not
just when the session is disposed. SendMessageAsync handles the
now-nullable field via the existing _getHttpResponseCompleted gate, and
any server-to-client messages sent after disconnect are still captured
by the event store writer for replay via Last-Event-ID.

Add a unit test that verifies _httpSseWriter is null once
HandleGetRequestAsync returns.

Relates to #766.
2026-06-05 16:52:49 -07:00
..
Client Make ClientTransportClosedException public and unify transport exception handling (#1467) 2026-03-29 20:21:03 -04:00
Configuration Fix process crash when testing Stderr (#1449) 2026-04-06 11:29:00 -07:00
Protocol Add 3-arg RequestContext constructor and obsolete 2-arg to eliminate null-forgiving operator usage (#1462) 2026-03-27 12:33:23 -07:00
Server Fix process crash when testing Stderr (#1449) 2026-04-06 11:29:00 -07:00
Transport Release SSE response stream reference when GET request ends 2026-06-05 16:52:49 -07:00
AIContentExtensionsTests.cs Fix base64 deserialization when JSON encoder escapes forward slashes (#1342) 2026-02-23 14:20:25 -05:00
ClientIntegrationTestFixture.cs Update tests for @modelcontextprotocol/server-everything 2026.1.26 (#1273) 2026-02-17 16:49:12 -08:00
ClientIntegrationTests.cs Add client completion notification and details (#1368) 2026-03-02 09:17:22 -05:00
ClientServerTestBase.cs Fix reserved expansion (e.g. "{+var}") when matching resources (#1142) 2026-01-27 17:23:31 -05:00
DiagnosticTests.cs Add stateless doc, prefer stateless mode and disable legacy SSE by default (#1468) 2026-03-27 13:56:16 -07:00
DockerEverythingServerTests.cs Update tests for @modelcontextprotocol/server-everything 2026.1.26 (#1273) 2026-02-17 16:49:12 -08:00
EverythingSseServerFixture.cs Centralize test timeout constants to fix CI flakiness (#1224) 2026-01-30 13:47:11 -08:00
ExperimentalInternalPropertyTests.cs Hide experimental types from external source generators using internal property pattern (#1301) 2026-02-19 07:27:30 -08:00
ExperimentalPropertySerializationTests.cs Hide experimental types from external source generators using internal property pattern (#1301) 2026-02-19 07:27:30 -08:00
GlobalUsings.cs Enable netfx testing. (#588) 2025-07-08 18:50:37 +03:00
IdentityAssertionGrantTests.cs feat: Add Enterprise Managed Authorization (SEP-990) support (#1305) 2026-06-03 16:34:59 -07:00
McpJsonUtilitiesTests.cs Fix NotSupportedException when returning IEnumerable<ContentBlock> (#675) 2025-08-05 14:36:11 -07:00
McpProtocolExceptionDataTests.cs Add 3-arg RequestContext constructor and obsolete 2-arg to eliminate null-forgiving operator usage (#1462) 2026-03-27 12:33:23 -07:00
ModelContextProtocol.Tests.csproj Add DistributedCacheEventStreamStore (#1136) 2026-02-03 15:48:57 -08:00
PlatformDetection.cs Add support for data to McpProtocolException (#1028) 2025-12-03 15:37:54 -08:00
RequestOptionsTests.cs Add McpClient/Session methods using .Protocol types (#1063) 2025-12-05 13:45:12 -05:00
StdioServerIntegrationTests.cs Centralize test timeout constants to fix CI flakiness (#1224) 2026-01-30 13:47:11 -08:00
TestAttributes.cs Add initial Activity / Metric support (#183) 2025-04-02 11:09:05 -04:00