While using Sentry, Glimpse.AspNet and Newtonsoft.Json.Glimpse, I ran into an issue where Sentry was unable to capture messages or exceptions. Take a look at the following stacktrace:
Exception thrown: 'System.NullReferenceException' in Glimpse.AspNet.dll
Error while processing event d3eae076461d4f7982837387f5c9ea7a: System.NullReferenceException: Object reference not set to an instance of an object.
at Glimpse.AspNet.AspNetFrameworkProvider.get_HttpRequestStore()
at Glimpse.Core.Framework.Factory.<>c__DisplayClass5.<InstantiateRuntimePolicyStrategy>b__4()
at Newtonsoft.Json.Glimpse.JsonSerializerSettingsFactory.IsGlimpseEnabled()
at Newtonsoft.Json.Glimpse.JsonSerializerSettingsFactory.GetDefaultSerializerSettings()
at Newtonsoft.Json.JsonSerializer.CreateDefault()
at Newtonsoft.Json.JsonSerializer.CreateDefault(JsonSerializerSettings settings)
at Sentry.Internal.JsonSerializer.SerializeObject[T](T object)
at Sentry.Internal.Http.HttpTransport.CreateRequest(SentryEvent event)
at Sentry.Internal.Http.HttpTransport.<CaptureEventAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Sentry.Internal.BackgroundWorker.<WorkerAsync>d__14.MoveNext(). #0 in queue.
Exception thrown: 'System.NullReferenceException' in Glimpse.AspNet.dll
If I had to guess, it seems Sentry wants to serialize something which triggers Newtonsoft.Json.Glimpse to check if Glimpse is enabled, but at this point in time HttpRequestStore is null, causing Glimpse.AspNet to throw an exception.
While using Sentry, Glimpse.AspNet and Newtonsoft.Json.Glimpse, I ran into an issue where Sentry was unable to capture messages or exceptions. Take a look at the following stacktrace:
If I had to guess, it seems Sentry wants to serialize something which triggers Newtonsoft.Json.Glimpse to check if Glimpse is enabled, but at this point in time
HttpRequestStore
is null, causing Glimpse.AspNet to throw an exception.At first I thought this was a Sentry issue, see https://github.com/getsentry/sentry-dotnet/issues/206