Nancy 应用程序错误被 OWIN 吞没?

Nancy application error being swallowed by OWIN?

我有一个 Nancy 应用程序,最近更新后可以使用 OWIN/Katana。

出于某种原因,我的“真实”错误现在被隐藏了。

这是我收到的唯一一般性错误:

A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.

Caused By: HttpException·The remote host closed the connection. The error code is 0x800704CD. :0System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect) :0System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush() :0System.Web.HttpResponse.Flush(Boolean finalFlush, Boolean async) :0Microsoft.Owin.Host.SystemWeb.CallStreams.OutputStream.Flush()
:0System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
:0System.IO.StreamWriter.Dispose(Boolean disposing)
:0System.IO.StreamWriter.Close()
:0Newtonsoft.Json.JsonWriter.System.IDisposable.Dispose()
:0Nancy.Serialization.JsonNet.JsonNetSerializer.Serialize(String contentType, TModel model, Stream outputStream)
:0Nancy.Owin.NancyMiddleware+<>c__DisplayClasse.b__a(NancyContext context)
:0System.Threading.Tasks.Task.Execute()

这不是真正的错误。出于某种原因,在我更新为使用 OWIN 后,我的真实错误不再被记录。

我的 OWIN 启动只有 app.UseNancy()(没有其他中间件)。

这是我在 ApplicationStartup 中的错误处理程序:

pipelines.OnError.AddItemToEndOfPipeline((context, exception) => OnError(container.Resolve<ILoggingService>(), context, exception));


private static Response OnError(ILoggingService loggingService, NancyContext context, Exception exception)
{
   // log something
}

我做错了什么?我现在必须编写自定义中间件来处理错误吗?

编辑

对此的更新。当它发生时,它实际上使我的 site/app 池崩溃。我在 .NET 4.5 上。

原来这不是 Nancy/OWIN 直接。

我使用的库 (BugSnag) 导致了问题。它似乎没有正确支持 OWIN。所以我删除了那个库,问题就停止了。