question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Async RequestPayloadExtractor?

See original GitHub issue

The 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
bruno-garciacommented, Dec 15, 2019

@lol768 It will be fixed soon.

2reactions
m4rcelplcommented, Jul 11, 2019

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 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lifetime issues when calling async function from request in ...
New to Rust and don't understand lifetimes very well yet. I'm trying to implement user auth, with active and return cookies.
Read more >
Extractors
Actix Web provides a facility for type-safe request information access ... Payload - Low-level payload extractor primarily for building other extractors.
Read more >
axum::extract - Rust
A handler function is an async function that takes any number of “extractors” as arguments. An extractor is a type that implements FromRequest...
Read more >
rust - How to use an extractor with from_request
I have tried using HttpRequest and web::dev::Payload extractors: #[post("/newsletter")] pub async fn publish_newsletter( ...
Read more >
FromRequest in actix_web - Rust
A type that implements FromRequest is called an extractor and can extract data from the request. Some types that implement this trait are:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found