Offline caching prevents error reports from iOS app
thomashejdoktor opened this issue · 2 comments
thomashejdoktor commented
Environment
How do you use Sentry?
Sentry SaaS (sentry.io)
SDK
Sentry.Xamarin 1.1.0
Device
iPhone 8, iOS 14.4.2
Steps to Reproduce
- Initialize SentryXamarin with the following options:
SentryXamarin.Init(o =>
{
o.Dsn = AppSettings.Instance.SentryDsn;
o.SendDefaultPii = false;
o.AttachStacktrace = true;
o.Debug = true;
};
- Throw nullexception in iOS app to verify Sentry has been initilalized.
Expected Result
Application crashes and an exception report is sent to Sentry.io console.
Actual Result
Application crashes but no exception report is sent to Sentry.io console.
Stacktrace
2021-06-23 10:14:20.495 Application.iOS[18946:3360565] Info: Capturing event.
2021-06-23 10:14:20.506 Application.iOS[18946:3360565] Debug: Running processor on exception: Sentry test ios
2021-06-23 10:14:20.511 Application.iOS[18946:3360565] Debug: Creating SentryStackTrace. isCurrentStackTrace: False.
Loaded assembly: /private/var/containers/Bundle/Application/7564202E-DA49-4955-AA15-13553B0D241E/Application.iOS.app/System.Threading.Tasks.Extensions.dll
2021-06-23 10:14:20.538 Application.iOS[18946:3360565] Debug: Running main event processor on: Event 2b66ec3e32584a4cb768e6fc88b670a6
2021-06-23 10:14:20.551 Application.iOS[18946:3360565] Debug: Envelope queued up.
2021-06-23 10:14:20.551 Application.iOS[18946:3360565] Info: Disposing the Hub.
2021-06-23 10:14:20.552 Application.iOS[18946:3360565] Debug: Disposing SentryClient.
2021-06-23 10:14:20.552 Application.iOS[18946:3360565] Debug: Disposing BackgroundWorker.
2021-06-23 10:14:20.554 Application.iOS[18946:3360622] Debug: Storing file /var/mobile/Containers/Data/Application/C12643CF-4CE8-45C4-A3B0-BBACFDF281EC/Documents/Sentry/28CE05E461034F7F5AAEDE4C9F962FF60F06F79A/1624436060_-2717_2b66ec3e32584a4cb768e6fc88b670a6_-588163899.envelope.
2021-06-23 10:14:20.589 Application.iOS[18946:3360622] Debug: Envelope 2b66ec3e32584a4cb768e6fc88b670a6 handed off to transport. #1 in queue.
2021-06-23 10:14:20.602 Application.iOS[18946:3360635] Debug: Flushing cached envelopes.
2021-06-23 10:14:20.602 Application.iOS[18946:3360630] Debug: Shutdown scheduled. Stopping by: 00:00:02. #0 in queue.
2021-06-23 10:14:20.602 Application.iOS[18946:3360630] Info: Exiting the worker with an empty queue.
2021-06-23 10:14:20.604 Application.iOS[18946:3360635] Debug: Reading cached envelope: /var/mobile/Containers/Data/Application/C12643CF-4CE8-45C4-A3B0-BBACFDF281EC/Documents/Sentry/28CE05E461034F7F5AAEDE4C9F962FF60F06F79A/__processing/1624436060_-2717_2b66ec3e32584a4cb768e6fc88b670a6_-588163899.envelope
2021-06-23 10:14:20.607 Application.iOS[18946:3360635] Error: Failed to send cached envelope: System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Sentry.Internal.Extensions.StreamExtensions+<ReadAllBytesAsync>d__0.MoveNext () [0x000b7] in /_/src/Sentry/Internal/Extensions/StreamExtensions.cs:18
at Sentry.Internal.Extensions.StreamExtensions+<ReadAllBytesAsync>d__0.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult (System.Int16 token) <0x108b132e0 + 0x0005f> in <21de525d6d944e1892c9b758d850e8d6#f76cceb590763b94e6fe78680461b832>:0
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:818
at Sentry.Protocol.Envelopes.Envelope.DeserializeHeaderAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x000a0] in /_/src/Sentry/Envelopes/Envelope.cs:140
at Sentry.Protocol.Envelopes.Envelope.DeserializeHeaderAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x0016b] in /_/src/Sentry/Envelopes/Envelope.cs:140
at Sentry.Protocol.Envelopes.Envelope.DeserializeAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x00032] in /_/src/Sentry/Envelopes/Envelope.cs:164
at Sentry.Internal.Http.CachingTransport.ProcessCacheAsync (System.Threading.CancellationToken cancellationToken) [0x0012c] in /_/src/Sentry/Internal/Http/CachingTransport.cs:176
at Sentry.Internal.Http.CachingTransport.ProcessCacheAsync (System.Threading.CancellationToken cancellationToken) [0x002e8] in /_/src/Sentry/Internal/Http/CachingTransport.cs:186 , retrying after a delay.
2021-06-23 10:14:20.607 Application.iOS[18946:3360635] Debug: Background worker of CachingTransport has shutdown.
2021-06-23 10:14:20.607 Application.iOS[18946:3360565] Debug: Disposing scope.
2021-06-23 10:14:20.607 Application.iOS[18946:3360565] Debug: Disposing SentryScopeManager.
Workaround
Disable offline caching for iOS.
lucas-zimerman commented
Hi @thomashejdoktor , would you mind giving a try if setting a higher timeout for the cache works for you?
for example:
SentryXamarin.Init(o =>
{
o.Dsn = AppSettings.Instance.SentryDsn;
o.SendDefaultPii = false;
o.InitCacheFlushTimeout = TimeSpan.FromSeconds(10);
o.AttachStacktrace = true;
o.Debug = true;
};
thomashejdoktor commented
Hi Lucas,
Thanks for looking into this.
I tried to increase the InitCacheFlushTimeout to 10 seconds, but it had no effect.
Instead I noticed that I got an error around System.Text.Json which led me to this issue #72.
The workaround provided in this answer #72 (comment) solved my problem.