MCP session disposal throws ObjectDisposedException by accessing an expired HttpContext
Mantenedores costumam responder em até 2 dias
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
Start with McpServer.cs around line 129 and trace RunSessionHandler through its finally block. Review the existing EndedSession_RemovesLocationSubscription test and add regression coverage for disposal after the initialization request ends. Done means teardown releases subscriptions and applicable legacy admission state without throwing an ObjectDisposedException; pull request #250 is already open against this issue.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Description
Observed with Cosmos DB Shell 1.1.280-preview on macOS through a VS Code MCP client. The account connection succeeded; session cleanup subsequently logged:
Error disposing session.
System.ObjectDisposedException: IFeatureCollection has been disposed.
Object name: 'Collection'.
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_Path()
at Azure.Data.Cosmos.Shell.Mcp.McpServer...
ConfigureHttpTransport... in McpServer.cs:line 137
at ModelContextProtocol.AspNetCore.StreamableHttpSession.DisposeAsync()
at ModelContextProtocol.AspNetCore.StatefulSessionManager.DisposeSessionAsync(...)
The unsafe access remains in McpServer.cs on main. The updated local main and origin/main both pointed to 6875685c6a2670ffcf85cdecff13420eea3a0a9b when checked.
Cause
RunSessionHandler awaits RunSessionAsync, then its finally block accesses httpContext.Request.Path and potentially httpContext.RequestServices. The originating HTTP request can already be disposed when the longer-lived MCP session ends.
This also affects non-legacy stateful sessions: evaluating the "/sse" condition itself dereferences the disposed context.
Expected Behavior
Session teardown completes without accessing expired request state, while releasing subscriptions and applicable legacy admission state.
Suggested Fix
Capture the legacy-transport decision and required singleton services before awaiting the session. Use only those captured values during cleanup.
Regression Coverage
Exercise session disposal after the initialization HTTP request has ended. Assert both successful cleanup and absence of disposal exceptions.
The existing EndedSession_RemovesLocationSubscription test checks subscription removal, but that cleanup occurs before the failing outer finally; it therefore does not establish error-free teardown.
Scope
The observed failure is in session cleanup. It does not establish that preceding tool calls failed or that unrelated Azure deployment operations were affected.
- Linguagem predominante
- C#
- Estrelas
- 4
- Forks
- 7
- Merge médio
- 2d 40min
- PRs com merge (30d)
- 30
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de Azure/CosmosDBShell
-
Support undefined partition keys (PartitionKey.None) across item commandsTalvez já em andamento @mkrueger assumiu há 2 dias. Aberta
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 15/100
Azure/CosmosDBShell#251 ·
Mantenedores costumam responder em até 2 dias
-
enhancement
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
Azure/CosmosDBShell#240 ·
Mantenedores costumam responder em até 2 dias
-
automation P1
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 45/100
Azure/CosmosDBShell#178 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
Lightweight headless CI distribution (no MCP, LSP, interactive UI)Talvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertaautomation P1
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
Azure/CosmosDBShell#175 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
agentic enhancement P0
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 55/100
Azure/CosmosDBShell#153 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
Todas as issues de Azure/CosmosDBShell
Issues semelhantes
-
needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
7.0
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
unoplatform/uno.extensions#3253 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Sector-Vestige/Sector-Vestige#476 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
PowerShell/platyPS#868 ·
-
S: Untriaged
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Trauma-Station/Trauma-Station#5058 ·
Mantenedores costumam responder em até 1 dia