Package
Sentry.Maui
.NET Flavor
.NET
.NET Version
9.0.101
OS
Any (not platform specific)
SDK Version
5.0.1
Self-Hosted Sentry Version
No response
Steps to Reproduce
- Run the Sentry.Samples.Maui app for a supported TFM
- Place a break point anywhere in the
Sentry.Maui.Internal.SentryMauiEventProcessor.Process method
- Tap
Throw and Capture Exception button
Expected Result
I expect only one instance of SentryMauiEventProcessor to exist and process the event.
Actual Result
Two instances of SentryMauiEventProcessor exist and both process the event.
Notes:
When a .NET MAUI app calls either of the MauiAppBuilder.UseSentry overloads, the SentryMauiOptions configurator, SentryMauiOptionsSetup, is registered with .NET’s dependency injection container twice — albeit via different means.
|
services.AddSingleton<IConfigureOptions<SentryMauiOptions>>(_ => new SentryMauiOptionsSetup(section)); |
|
services.AddSingleton<IConfigureOptions<SentryMauiOptions>, SentryMauiOptionsSetup>(); |
As a consequence, SentryMauiOptions gets configured twice (two calls to Sentry.Maui.Internal.SentryMauiOptionsSetup.Configure during MauiAppBuilder.Build), two instances of SentryMauiEventProcessor are newed-up and added to the processing pipeline (source), and both act on an event.
Adding some logging to the Process method shows:
Info: SentryMauiEventProcessor with InstanceId: 12af7053-540e-43d6-a866-37d784dde85d processed EventId: 0b6f8c02a7604555a14c08627402839a
Info: SentryMauiEventProcessor with InstanceId: 95fae520-c882-499d-8bcc-85670c331948 processed EventId: 0b6f8c02a7604555a14c08627402839a
While this doesn’t appear to have any major side-effects (that I can immediately see) it's probably something that should be fixed.
Package
Sentry.Maui
.NET Flavor
.NET
.NET Version
9.0.101
OS
Any (not platform specific)
SDK Version
5.0.1
Self-Hosted Sentry Version
No response
Steps to Reproduce
Sentry.Maui.Internal.SentryMauiEventProcessor.ProcessmethodThrow and Capture ExceptionbuttonExpected Result
I expect only one instance of
SentryMauiEventProcessorto exist and process the event.Actual Result
Two instances of
SentryMauiEventProcessorexist and both process the event.Notes:
When a .NET MAUI app calls either of the
MauiAppBuilder.UseSentryoverloads, theSentryMauiOptionsconfigurator,SentryMauiOptionsSetup, is registered with .NET’s dependency injection container twice — albeit via different means.sentry-dotnet/src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs
Line 48 in 5a83313
sentry-dotnet/src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs
Line 58 in 5a83313
As a consequence,
SentryMauiOptionsgets configured twice (two calls to Sentry.Maui.Internal.SentryMauiOptionsSetup.Configure duringMauiAppBuilder.Build), two instances ofSentryMauiEventProcessorare newed-up and added to the processing pipeline (source), and both act on an event.Adding some logging to the
Processmethod shows:While this doesn’t appear to have any major side-effects (that I can immediately see) it's probably something that should be fixed.