MindscapeHQ / raygun4net

Raygun provider for .NET
https://raygun.com
MIT License
126 stars 93 forks source link

#421 No need to clear the current HttpContext when populating #440

Closed knumat closed 9 months ago

knumat commented 4 years ago

This caused a subtle bug where the first exception reported would include the request context, but subsequent exceptions would not.

In addition, the AspNetCore version would never set the StatusCode or StatusDescription in the Response since _currentHttpContext was set to null by BuildRequestMessage() just before BuildResponseMessage() was called. Note that StatusCode would not typically be set if an exception occurred on ASP.NET Core since the Raygun HTTP module does not exist on this platform, but custom middleware might want to do this. For example, custom middleware might watch for certain HTTP status codes and report them.

As long as RaygunClient objects are short-lived, this should not cause any memory leaks.

mduncan26 commented 4 years ago

Hi @knumat

Thank you for the PR we will updater this thread once we have had a chance to review the changes.

Regards, Mitchell.

phillip-haydon commented 9 months ago

This will be resolved in #518 by using IHttpContextAccessor and passing the info in rather than attempting to store the data locally in the RaygunClient (RaygunClient should be treated as a singleton)