-
-
Notifications
You must be signed in to change notification settings - Fork 372
fix: HTTP Client errors mark session as errored #6633
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
base: main
Are you sure you want to change the base?
Conversation
Automatically captured HTTP client errors now mark sessions as errored. Fixes GH-3742
❌ 3 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 3279d4e | 1215.76 ms | 1256.45 ms | 40.69 ms |
| 37183fe | 1212.33 ms | 1238.92 ms | 26.59 ms |
| 80a5166 | 1224.49 ms | 1251.29 ms | 26.80 ms |
| 0b5fd21 | 1237.52 ms | 1251.36 ms | 13.84 ms |
| 8745cc0 | 1228.13 ms | 1250.48 ms | 22.35 ms |
| ebc72be | 1221.24 ms | 1249.66 ms | 28.42 ms |
| 0b6776b | 1230.18 ms | 1262.06 ms | 31.88 ms |
| 6e99155 | 1223.96 ms | 1249.25 ms | 25.29 ms |
| e8f9a1d | 1229.02 ms | 1264.17 ms | 35.15 ms |
| 535ebd9 | 1194.59 ms | 1219.84 ms | 25.26 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 3279d4e | 23.75 KiB | 938.32 KiB | 914.57 KiB |
| 37183fe | 23.75 KiB | 913.63 KiB | 889.87 KiB |
| 80a5166 | 23.75 KiB | 904.53 KiB | 880.78 KiB |
| 0b5fd21 | 23.75 KiB | 912.78 KiB | 889.03 KiB |
| 8745cc0 | 23.74 KiB | 971.81 KiB | 948.07 KiB |
| ebc72be | 23.75 KiB | 908.22 KiB | 884.47 KiB |
| 0b6776b | 23.75 KiB | 968.23 KiB | 944.49 KiB |
| 6e99155 | 23.75 KiB | 963.18 KiB | 939.43 KiB |
| e8f9a1d | 23.75 KiB | 969.78 KiB | 946.04 KiB |
| 535ebd9 | 23.75 KiB | 1008.67 KiB | 984.92 KiB |
Previous results on branch: fix/client-error-session-error
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| f67de13 | 1212.63 ms | 1242.78 ms | 30.15 ms |
| 016277f | 1218.59 ms | 1258.81 ms | 40.22 ms |
| 99ac7d1 | 1212.64 ms | 1237.16 ms | 24.52 ms |
| e886f08 | 1213.26 ms | 1242.90 ms | 29.64 ms |
| 26f6484 | 1214.64 ms | 1247.59 ms | 32.95 ms |
| 23a141f | 1220.30 ms | 1253.12 ms | 32.82 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| f67de13 | 23.75 KiB | 1.00 MiB | 1001.01 KiB |
| 016277f | 23.75 KiB | 1.00 MiB | 1001.09 KiB |
| 99ac7d1 | 23.75 KiB | 1.02 MiB | 1016.55 KiB |
| e886f08 | 23.75 KiB | 1.02 MiB | 1020.21 KiB |
| 26f6484 | 23.75 KiB | 1.00 MiB | 1001.02 KiB |
| 23a141f | 23.75 KiB | 1.02 MiB | 1016.68 KiB |
Sources/Sentry/SentryClient.m
Outdated
| additionalEnvelopeItems:additionalEnvelopeItems]; | ||
| } | ||
|
|
||
| - (SentryId *)captureErrorEvent:(SentryEvent *)event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add tests for that method because it's covered by the existing tests of captureException and captureError.
|
Failing UI tests will be fixed with #6650. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost LGTM
Sources/Sentry/SentryHub.m
Outdated
|
|
||
| - (SentryId *)captureException:(NSException *)exception withScope:(SentryScope *)scope | ||
| { | ||
| SentryId * (^captureClientBlock)(SentryClientInternal *) = ^SentryId *( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: In previous PR feedback you mentioned that we should refrain from using NSBlock due to it's instability and memory unsafety. We should consider using private methods instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should refrain from using NSBlock due to it's instability and memory unsafety.
When you're using async code and you're referencing other objects in it, yes. In this case, it should be good, but I also hate the syntax a lot, so let's do private methods instead. Thanks for pointing it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } else { | ||
| _errorsBeforeSession++; | ||
| return [client captureException:exception withScope:scope]; | ||
| return captureClientSessionNilBlock(client); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Inconsistent Error Capture Without Active Session Block
The refactoring uses blocks for event capture, which goes against a prior agreement. More critically, in captureErrorEvent:, when no session is active, the captureClientBlockSessionNil block calls captureEvent:withScope:. This causes error events to miss stack traces, creating inconsistent behavior compared to other error capture methods and expected error event data.
|
Back to draft, because I'm trying to get rid of many NSBlocks. |
🚨 Detected changes in high risk code 🚨High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:
|
📜 Description
Automatically captured HTTP client errors now mark sessions as errored.
💡 Motivation and Context
Fixes GH-3742
💚 How did you test it?
Unit tests and manually capturing a HTTP client error via the sample app: https://sentry-sdks.sentry.io/explore/releases/philipp-test-client-errors%2B1.0.0/?issuesType=all&project=5428557
📝 Checklist
You have to check all boxes before merging:
sendDefaultPIIis enabled.