Async RequestPayloadExtractor?
See original GitHub issueThe DefaultRequestPayloadExtractor has a comment stating that there would be no real value in making it asynchronous. https://github.com/getsentry/sentry-dotnet/blob/e24115df3869601fb51a3d37392ae031a9ddb83b/src/Sentry/Extensibility/DefaultRequestPayloadExtractor.cs#L21
Whilst there might not be any gain in performance by making it async, I would like to suggest a scenario where there would be value in doing so.
There is nowhere in our APIs where we need to use synchronous IO, so to prevent developers from doing so accidentally, we configure Kestrel to disallow it:
builder.UseKestrel(options =>
{
options.AllowSynchronousIO = false;
});
However setting those Kestrel options combined with Sentry reading the body synchronously means that when logging an exception to Sentry, we get an additional exception in the breadcrumbs in the event and the request body is also not part of the event because it could not be read.
Failed invoking event handler: System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadToEnd()
at Sentry.Extensibility.DefaultRequestPayloadExtractor.DoExtractPayLoad(IHttpRequest request) in C:\projects\sentry-dotnet\src\Sentry\Extensibility\DefaultRequestPayloadExtractor.cs:line 22
at Sentry.Extensibility.BaseRequestPayloadExtractor.ExtractPayload(IHttpRequest request) in C:\projects\sentry-dotnet\src\Sentry\Extensibility\BaseRequestPayloadExtractor.cs:line 19
at Sentry.Extensibility.RequestBodyExtractionDispatcher.ExtractPayload(IHttpRequest request) in C:\projects\sentry-dotnet\src\Sentry\Extensibility\RequestBodyExtractionDispatcher.cs:line 41
at Sentry.AspNetCore.ScopeExtensions.SetBody(BaseScope scope, HttpContext context, SentryAspNetCoreOptions options) in C:\projects\sentry-dotnet\src\Sentry.AspNetCore\ScopeExtensions.cs:line 109
at Sentry.AspNetCore.ScopeExtensions.Populate(Scope scope, HttpContext context, SentryAspNetCoreOptions options) in C:\projects\sentry-dotnet\src\Sentry.AspNetCore\ScopeExtensions.cs:line 43
at Sentry.AspNetCore.SentryMiddleware.PopulateScope(HttpContext context, Scope scope) in C:\projects\sentry-dotnet\src\Sentry.AspNetCore\SentryMiddleware.cs:line 143
at Sentry.Scope.Evaluate() in C:\projects\sentry-dotnet\src\Sentry\Scope.cs:line 135
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top GitHub Comments
@lol768 It will be fixed soon.
In .NET Core 3 (preview 6) options.AllowSynchronousIO i set to false by default and sentry generate this error ;/ Manual set this to true solving a problem. Please set higher priority 😃