datalust/seq-extensions-logging

Use of async void leading to InvalidOperationException on ASP.NET WebForms

ShutterQuick opened this issue · 3 comments

Hi,

An asynchronous module or handler completed while an asynchronous operation was still pending.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: An asynchronous module or handler completed while an asynchronous operation was still pending.

This use of async void prevents the task to be properly tracked by the ASP.NET WebForms.
Relevant info: https://stackoverflow.com/a/17660475

It's not immediately obvious to me what the purpose of doing it like this is.
Could you have a look at it, and consider removing AsObserved() and instead just do .ConfigureAwait(false) directly?

I've tested doing that, and it makes my problem go away.

Thanks for the heads-up - this code was originally derived from Serilog.Sinks.PeriodicBatching, which has subsequently been updated to fix a few issues like this. We'll re-import the Serilog version of the code, which no longer includes the problematic section 👍

@ShutterQuick there should be a 6.0.0-dev-* version published to NuGet with this fix in just a moment. It would be great to hear how it goes for you. Thanks again!

Thank you for the super quick turnaround!
Looks like it's working properly now for my use case, thanks a lot!