question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disposing the Hub with AutoSessionTracking gives an error

See original GitHub issue

As observed on Unity, when you dispose of a hub and usingAutoSessionTracking, an error will be thrown once the SDK disposes of the SDK hub. You can reproduce the error with the following snippet:

void StartSentry()
{
    SentrySdk.Init(o =>
    {
        o.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537";
        o.AutoSessionTracking = true;
        o.CacheDirectoryPath = "C:/Users/.../AppData/LocalLow/Sentry/Sentry Defenses/Sentry";
        o.Debug = true;
    });
}
StartSentry();
StartSentry();
Console.ReadKey();

The following error was received:

Error: Failed to send cached envelope: C:/Users/lucas/AppData/LocalLow/Sentry/Sentry Defenses/Sentry\Sentry\132A73C90BBA506000857BC4BFC23E574F1551B5\__processing\1638992610_1647__6590935.envelope, retrying after a delay.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at Sentry.Internal.Extensions.StreamExtensions.ReadAllBytesAsync(Stream stream, CancellationToken cancellationToken)+MoveNext() in D:\Development\Online Projects\Sentry\sentry-dotnet\src\Sentry\Internal\Extensions\StreamExtensions.cs:line 18
   at Sentry.Internal.Extensions.StreamExtensions.ReadAllBytesAsync(Stream stream, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at Sentry.Protocol.Envelopes.Envelope.DeserializeHeaderAsync(Stream stream, CancellationToken cancellationToken) in D:\Development\Online Projects\Sentry\sentry-dotnet\src\Sentry\Envelopes\Envelope.cs:line 188
   at Sentry.Protocol.Envelopes.Envelope.DeserializeHeaderAsync(Stream stream, CancellationToken cancellationToken) in D:\Development\Online Projects\Sentry\sentry-dotnet\src\Sentry\Envelopes\Envelope.cs:line 188
   at Sentry.Protocol.Envelopes.Envelope.DeserializeAsync(Stream stream, CancellationToken cancellationToken) in D:\Development\Online Projects\Sentry\sentry-dotnet\src\Sentry\Envelopes\Envelope.cs:line 212
   at Sentry.Internal.Http.CachingTransport.InnerProcessCacheAsync(String envelopeFilePath, CancellationToken cancellationToken) in D:\Development\Online Projects\Sentry\sentry-dotnet\src\Sentry\Internal\Http\CachingTransport.cs:line 195
   at Sentry.Internal.Http.CachingTransport.InnerProcessCacheAsync(String envelopeFilePath, CancellationToken cancellationToken) in D:\Development\Online Projects\Sentry\sentry-dotnet\src\Sentry\Internal\Http\CachingTransport.cs:line 207
   at Sentry.Internal.Http.CachingTransport.ProcessCacheAsync(CancellationToken cancellationToken) in D:\Development\Online Projects\Sentry\sentry-dotnet\src\Sentry\Internal\Http\CachingTransport.cs:line 159  Debug: Background worker of CachingTransport has shutdown.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vaindcommented, Jul 11, 2022

so should we throw on the second init call?

That would be breaking though, wouldn’t it?

1reaction
SimonCroppcommented, Dec 22, 2021

Init is supposed to be called once in the app lifecycle

so should we throw on the second init call?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Basic Options for Browser JavaScript
By default, all errors are sent. autoSessionTracking. When set to true , the SDK will send session events to Sentry. This is supported...
Read more >
Sessions | Sentry Developer Documentation
Sessions and error events are two distinct systems within Sentry. Session updates can be done without error events to be sent and likewise,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found