Skip to content

[MAUI] Duplicate SentryMauiEventProcessors #3894

Closed
@phunkeler

Description

@phunkeler

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

  1. Run the Sentry.Samples.Maui app for a supported TFM
  2. Place a break point anywhere in the Sentry.Maui.Internal.SentryMauiEventProcessor.Process method
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions