Skip to content

Commit 5e33a72

Browse files
authored
Merge pull request #72 from mayuki/hotfix/IgnoreExceptionOnAborted
Skip Exception logging if the connection is aborted
2 parents 7662369 + ac53159 commit 5e33a72

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Rin/Middlewares/RequestRecorderMiddleware.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System.Linq;
1616
using System.Threading.Tasks;
1717
using Microsoft.AspNetCore.Http.Features;
18+
using Microsoft.AspNetCore.Connections;
1819

1920
namespace Rin.Middlewares
2021
{
@@ -91,7 +92,13 @@ record = await PreprocessAsync(context, options, timelineRoot);
9192
}
9293
catch (Exception ex)
9394
{
94-
_logger.LogError(ex, "Unhandled Exception was thrown until post-processing");
95+
var skipLogging = context.RequestAborted.IsCancellationRequested ||
96+
(ex is IOException && ex.InnerException is ConnectionAbortedException);
97+
98+
if (!skipLogging)
99+
{
100+
_logger.LogError(ex, "Unhandled Exception was thrown until post-processing");
101+
}
95102
}
96103
}
97104
}

0 commit comments

Comments
 (0)