MCP session disposal throws ObjectDisposedException by accessing an expired HttpContext
Los mantenedores suelen responder en 2 días
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 4
- Forks
- 7
- Merge medio
- 2 d 13 min
- PR fusionados (30 d)
- 30
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Azure/CosmosDBShell
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
Azure/CosmosDBShell#251 ·
Los mantenedores suelen responder en 2 días
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Azure/CosmosDBShell#240 ·
Los mantenedores suelen responder en 2 días
-
automation P1
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
Azure/CosmosDBShell#178 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Lightweight headless CI distribution (no MCP, LSP, interactive UI)Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertoautomation P1
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Azure/CosmosDBShell#175 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
agentic enhancement P0
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Azure/CosmosDBShell#153 · 1 comentario ·
Los mantenedores suelen responder en 2 días
Todos los issues de Azure/CosmosDBShell
Issues similares
-
area-signalr
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
dotnet/aspnetcore#69842 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 2 días
-
bug needs-triage
Dificultad 2/5 Menos de una hora Aptitud para principiantes 78/100
microsoft/microsoft-ui-reactor#1373 ·
Los mantenedores suelen responder en 1 día
-
Client customer-reported KeyVault needs-team-attention question Service Attention
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Azure/azure-sdk-for-net#63861 · 3 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día