Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Deleting old envelopes for empty DSN #2562

Merged
merged 1 commit into from
Jan 3, 2023

Conversation

philipphofmann
Copy link
Member

@philipphofmann philipphofmann commented Dec 28, 2022

📜 Description

The SentryFileManager doesn't append the DSN hash to the basePath if the DSN is nil. We didn't handle this edge case when deleting old envelopes. This is fixed now.

💡 Motivation and Context

Came up while investigating flaky tests, such as https://github.com/getsentry/sentry-cocoa/actions/runs/3792592319.

Test Case '-[SentryTests.SentrySystemEventBreadcrumbsTest testBatteryChargingStateBreadcrumb]' started.
2022-12-28 08:11:48.336935+0000 xctest[7787:30340] [Sentry] [debug] [SentryFileManager:644] SentryFileManager.cachePath: /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches
2022-12-28 08:11:48.337176+0000 xctest[7787:30340] [Sentry] [debug] [SentryFileManager:227] Deleting /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/5f62ec4a55360b39302e7fc4c45703c42e9b08ae/events
2022-12-28 08:11:48.337847+0000 xctest[7787:44511] [Sentry] [debug] [SentryFileManager:84] Dispatched deletion of old envelopes from <SentryFileManager: 0x600000ab5a40>
2022-12-28 08:11:48.337938+0000 xctest[7787:30340] [Sentry] [debug] [SentryHttpTransport:251] sendAllCachedEnvelopes start.
2022-12-28 08:11:48.338870+0000 xctest[7787:30340] [Sentry] [debug] [SentryHttpTransport:263] No envelopes left to send.
2022-12-28 08:11:48.339303+0000 xctest[7787:30340] [Sentry] [debug] [SentryHttpTransport:342] Finished sending.
2022-12-28 08:11:48.340592+0000 xctest[7787:30340] [Sentry] [debug] [SentryFileManager:590] Reading timezone offset
2022-12-28 08:11:48.340891+0000 xctest[7787:44511] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x600007558570 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:11:48.341192+0000 xctest[7787:30340] [Sentry] [debug] [SentryFileManager:597] No timezone offset found.
2022-12-28 08:12:02.962875+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x600003474360 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.965979+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x6000035be130 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.968790+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x6000035be820 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.971517+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x6000035dd5c0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.974453+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x6000035bef10 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.977313+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x600003475680 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.980107+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x600003475d70 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.982909+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x600003476430 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.985640+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x6000035ddcb0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.988434+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x600003476b20 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.991166+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x6000035de3a0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.994023+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x6000035bf600 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.996786+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x6000035dea90 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:02.999644+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x600003477210 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2022-12-28 08:12:03.002419+0000 xctest[14859:46529] [Sentry] [error] [SentryFileManager:216] Couldn't load files in folder /Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes: Error Domain=NSCocoaErrorDomain Code=260 "The folder “envelopes” doesn’t exist." UserInfo={NSUserStringVariant=(
    Folder
), NSFilePath=/Users/runner/Library/Developer/CoreSimulator/Devices/DB259A71-C861-4F5F-8C86-76C405AD45E4/data/Library/Caches/io.sentry/envelopes/envelopes, NSUnderlyingError=0x600003477900 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

Restarting after unexpected exit, crash, or test timeout in SentrySystemEventBreadcrumbsTest.testBatteryChargingStateBreadcrumb(); summary will include totals from previous launches.

💚 How did you test it?

Unit tests

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • Review from the native team if needed
  • No breaking changes

🔮 Next steps

The SentryFileManager doesn't append the DSN hash to the basePath if the
DSN is nil. We didn't handle this edge case when deleting old envelopes. This
is fixed now.
@codecov
Copy link

codecov bot commented Dec 28, 2022

Codecov Report

Merging #2562 (dd8823e) into 8.0.0 (04beb80) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##            8.0.0    #2562      +/-   ##
==========================================
+ Coverage   79.09%   79.16%   +0.07%     
==========================================
  Files         243      243              
  Lines       22278    22280       +2     
  Branches     9854     9855       +1     
==========================================
+ Hits        17620    17639      +19     
+ Misses       4203     4189      -14     
+ Partials      455      452       -3     
Impacted Files Coverage Δ
Sources/Sentry/SentryFileManager.m 95.04% <100.00%> (+0.06%) ⬆️
...SentryCrash/Recording/Tools/SentryCrashJSONCodec.c 81.30% <0.00%> (-0.03%) ⬇️
Sources/SentryCrash/Recording/SentryCrashDoctor.m 15.87% <0.00%> (+0.13%) ⬆️
Sources/Sentry/SentryThreadHandle.cpp 69.39% <0.00%> (+1.09%) ⬆️
Sources/Sentry/SentryBacktrace.cpp 88.39% <0.00%> (+1.78%) ⬆️
Sources/Sentry/SentryThreadInspector.m 97.93% <0.00%> (+2.06%) ⬆️
Sources/SentryCrash/Recording/Tools/fishhook.c 82.27% <0.00%> (+5.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04beb80...dd8823e. Read the comment docs.

@github-actions
Copy link

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1233.56 ms 1242.82 ms 9.26 ms
Size 20.75 KiB 405.14 KiB 384.39 KiB

Baseline results on branch: 8.0.0

Startup times

Revision Plain With Sentry Diff
1b9c43b 1227.16 ms 1244.28 ms 17.12 ms
d914052 1236.52 ms 1251.56 ms 15.04 ms
4a67681 1216.33 ms 1242.29 ms 25.96 ms
b696ae1 1229.64 ms 1246.94 ms 17.30 ms
f81c2c4 1216.88 ms 1234.42 ms 17.54 ms
bd7cfa8 1223.45 ms 1237.40 ms 13.95 ms
5da2d48 1209.52 ms 1232.16 ms 22.64 ms
10f5348 1206.36 ms 1231.18 ms 24.82 ms
1018de3 1244.08 ms 1254.63 ms 10.55 ms
a0c8696 1239.33 ms 1261.92 ms 22.59 ms

App size

Revision Plain With Sentry Diff
1b9c43b 20.75 KiB 404.13 KiB 383.37 KiB
d914052 20.75 KiB 383.89 KiB 363.13 KiB
4a67681 20.75 KiB 405.06 KiB 384.31 KiB
b696ae1 20.75 KiB 383.77 KiB 363.01 KiB
f81c2c4 20.75 KiB 402.12 KiB 381.36 KiB
bd7cfa8 20.75 KiB 402.12 KiB 381.36 KiB
5da2d48 20.75 KiB 383.77 KiB 363.01 KiB
10f5348 20.75 KiB 402.12 KiB 381.36 KiB
1018de3 20.75 KiB 402.08 KiB 381.33 KiB
a0c8696 20.75 KiB 383.89 KiB 363.14 KiB

@philipphofmann philipphofmann enabled auto-merge (squash) December 29, 2022 07:10
@philipphofmann philipphofmann merged commit 5c0dd24 into 8.0.0 Jan 3, 2023
@philipphofmann philipphofmann deleted the fix/old-envelopes-empty-dsn branch January 3, 2023 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants