Skip to content

Errors when initializing Sentry twice with caching enabled #2033

Closed

Description

@mattjohnsonpint

Package

Sentry

.NET Version

6.0.402

SDK Version

3.23.1

Steps to Reproduce

var options = new SentryOptions()
{
    Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537",
    CacheDirectoryPath = "temp",
    IsGlobalModeEnabled = true,
    AutoSessionTracking = true,
    Debug = true
};

SentrySdk.Init(options);
SentrySdk.Init(options);

Console.Read();

Expected Result

With AutoSessionTracking = true, a session event should be created upon initialization.

Since we initialized twice, the hub should swap, causing two sessions. Both should be sent to Sentry without error.

Actual Result

A loop starts where many envelopes get created and destroyed before ultimately we get either a FileNotFoundException or an IOException

System.IO.FileNotFoundException
Could not find file '/Users/matt/Code/getsentry/sentry-dotnet/samples/Sentry.Samples.Console.Basic/bin/Debug/net6.0/temp/Sentry/132A73C90BBA506000857BC4BFC23E574F1551B5/__processing/1667863102_-2033__46292699.envelope'.
System.IO.IOException
The process cannot access the file '/Users/matt/Code/getsentry/sentry-dotnet/samples/Sentry.Samples.Console.Basic/bin/Debug/net6.0/temp/Sentry/132A73C90BBA506000857BC4BFC23E574F1551B5/__processing/1667862382_-3618__37710717.envelope' because it is being used by another process.

Full debug log: log.txt

Activity

  1. mattjohnsonpint commented on Nov 7, 2022

    @mattjohnsonpint
    ContributorAuthor

    Testing with many older versions, it looks like this has always been an issue. It's not a regression.

  2. mattjohnsonpint commented on Nov 8, 2022

    @mattjohnsonpint
    ContributorAuthor

    This may be the same as #1067, just with multiple hubs in the same process rather than multiple processes.

  3. removed theissue type on Aug 6, 2025
  4. added
    .NETPull requests that update .net code
    on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

.NETPull requests that update .net codeBugSomething isn't working

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions