File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
src/ModelContextProtocol.AspNetCore Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,11 @@ internal sealed class HttpMcpSession<TTransport>(
3939
4040 public IAsyncDisposable AcquireReference ( )
4141 {
42- Debug . Assert ( _idleSessionSemaphore is not null , "Only StreamableHttpHandler should call AcquireReference." ) ;
42+ // We don't do idle tracking for stateless sessions, so we don't need to acquire a reference.
43+ if ( _idleSessionSemaphore is null )
44+ {
45+ return new NoopDisposable ( ) ;
46+ }
4347
4448 lock ( _referenceCountLock )
4549 {
@@ -131,4 +135,9 @@ public async ValueTask DisposeAsync()
131135 }
132136 }
133137 }
138+
139+ private sealed class NoopDisposable : IAsyncDisposable
140+ {
141+ public ValueTask DisposeAsync ( ) => ValueTask . CompletedTask ;
142+ }
134143}
You can’t perform that action at this time.
0 commit comments