-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Describe the bug
A few .NET Core applications running in the Azure Service Fabric cluster are crashing several times per day with the exception: System.ObjectDisposedException: IFeatureCollection has been disposed.
To Reproduce
Unfortunately, I was not able to reproduce the issue on my machine. I suspect that might be caused by IHttpContextAccessor use in a singleton class. I am not capturing the HttpContext in a private field, nor using async void anywhere. I have ruled out all the bad practices mentioned in the guide by @davidfowl:
Exceptions (if any)
Application: service.exe
CoreCLR Version: 4.700.20.41105
.NET Core Version: 3.1.8
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ObjectDisposedException: IFeatureCollection has been disposed.
Object name: 'Collection'.
at Microsoft.AspNetCore.Http.Features.FeatureReferences`1.ThrowContextDisposed()
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_Scheme()
at Microsoft.AspNetCore.Http.Extensions.UriHelper.GetDisplayUrl(HttpRequest request)
at IFBaltics.Hosting.WebHostRequestFiller.Fill(LogEventInfo logEventInfo)
at Sysmsg.SysmsgLogCommand.Write()
at Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args)
at Microsoft.AspNetCore.Server.HttpSys.DisconnectListener.<>c__DisplayClass7_0.<CreateDisconnectToken>b__0(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* overlappedPtr)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pNativeOverlapped)
Further technical details
-
ASP.NET Core version 3.1.8
-
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-downloadHost (useful for support):
Version: 3.1.8
Commit: 9c1330dedd.NET Core SDKs installed:
No SDKs were found..NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.21 [c:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.21 [c:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.8 [c:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.21 [c:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.8 [c:\Program Files\dotnet\shared\Microsoft.NETCore.App]To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download -
Not dependant on the IDE.