#65702·aspnetcore

[已知构建错误] TestServerTests.LongPollingWorks - 在关闭期间,OnDisconnectedAsync 方法中发生 ObjectDisposedException

作者: lewing创建于 2026年3月7日更新于 2026年9月17日
标签area-signalrKnown Build Error

Build Information

Build: https://dev.Azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=1325148 Build error leg or test failing: Tests: Helix x64 Subset 2 / Microsoft.AspNetCore.SignalR.Client.Tests--net11.0 Pull Request: https://GitHub.com/dotnet/aspnetcore/pull/65694

Error Message

json
{
  "ErrorMessage": "Error when dispatching 'OnDisconnectedAsync' on hub",
  "BuildRetry": true,
  "ExcludeConsoleLog": false
}
## Description
`TestServerTests.LongPollingWorks` intermittently fails when the test host shuts down and `OnDisconnectedAsync` races with `IServiceProvider` disposal. The `HttpConnectionDispatcher.ProcessDeleteAsync` fire-and-forgets server-side connection disposal, so when the host tears down, `DefaultHubDispatcher.OnDisconnectedAsync` can attempt to call `CreateAsyncScope()` on an already-disposed `ServiceProvider`, throwing `ObjectDisposedException`.
**Stack trace:**

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'IServiceProvider'. at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException() at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateScope() at Microsoft.Extensions.DependencyInjection.ServiceProviderEngineScope.CreateScope() at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.CreateAsyncScope(IServiceScopeFactory serviceScopeFactory) at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher1.OnDisconnectedAsync(HubConnectionContext connection, Exception exception) at Microsoft.AspNetCore.SignalR.HubConnectionHandler1.RunHubAsync(HubConnectionContext connection)

Fix in progress: https://GitHub.com/dotnet/aspnetcore/pull/65457 catches ObjectDisposedException at the DI boundary in DefaultHubDispatcher.OnDisconnectedAsync.

Known issue validation

Build: :mag_right: https://dev.Azure.com/dnceng-public/public/_build/results?buildId=1325148 Error message validated: [Error when dispatching 'OnDisconnectedAsync' on hub] Result validation: :white_check_mark: Known issue matched with the provided build. Validation performed at: 3/7/2026 10:12:12 PM UTC

Report

Build Repository Step Name Console log Pull Request
1598302 dotnet/aspnetcore Run E2E tests Log dotnet/aspnetcore#69332
1597797 dotnet/aspnetcore Run E2E tests Log dotnet/aspnetcore#69327

内容来源: dotnet/aspnetcore