Skip to content

Errors when initializing Sentry twice with caching enabled #2033

@mattjohnsonpint

Description

@mattjohnsonpint

Package

Sentry

.NET Version

6.0.402

SDK Version

3.23.1

Steps to Reproduce

var options = new SentryOptions()
{
    Dsn = "https://[email protected]/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

Metadata

Metadata

Labels

BugSomething isn't working

Projects

Status

Backlog

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions