Skip to content

Conversation

@philipphofmann
Copy link
Member

📜 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

Screenshot 2025-11-03 at 11 53 57

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

@codecov
Copy link

codecov bot commented Nov 3, 2025

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
3980 3 3977 16
View the top 3 failed test(s) by shortest run time
iOS_SwiftUI_UITests.LaunchUITests::testCaptureErrorReturnsValidId
Stack Traces | 0s run time
.../iOS-SwiftUI/iOS-SwiftUI-UITests/LaunchUITests.swift:57 - Failed to get matching snapshot: Timed out while evaluating UI query.
iOS_SwiftUI_UITests.LaunchUITests::testNoNewTransactionForSecondCallToBody
Stack Traces | 0s run time
.../iOS-SwiftUI/iOS-SwiftUI-UITests/LaunchUITests.swift:39 - Failed to get matching snapshot: Timed out while evaluating UI query.
iOS_SwiftUI_UITests.LaunchUITests::testTransactionSpan
Stack Traces | 0s run time
.../iOS-SwiftUI/iOS-SwiftUI-UITests/LaunchUITests.swift:19 - Failed to get matching snapshots: Timed out while evaluating UI query.

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1228.92 ms 1259.16 ms 30.24 ms
Size 23.75 KiB 1.00 MiB 1001.07 KiB

Baseline results on branch: main

Startup times

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

additionalEnvelopeItems:additionalEnvelopeItems];
}

- (SentryId *)captureErrorEvent:(SentryEvent *)event
Copy link
Member Author

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.

@philipphofmann philipphofmann marked this pull request as ready for review November 3, 2025 15:53
@philipphofmann
Copy link
Member Author

Failing UI tests will be fixed with #6650.

Copy link
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost LGTM


- (SentryId *)captureException:(NSException *)exception withScope:(SentryScope *)scope
{
SentryId * (^captureClientBlock)(SentryClientInternal *) = ^SentryId *(
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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);
Copy link

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.

Fix in Cursor Fix in Web

@philipphofmann
Copy link
Member Author

Back to draft, because I'm trying to get rid of many NSBlocks.

@philipphofmann philipphofmann marked this pull request as draft November 4, 2025 15:57
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

🚨 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:

  • Sources/Sentry/SentryNetworkTracker.m

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.

HTTP Client Errors don't impact session

3 participants