Skip to content

Commit c51bd77

Browse files
fix: Don't send error 429 as network_error (#1957)
The docs state that errors with status code 429 should not be sent as network_error. The SDK didn't follow this rule yet.
1 parent f5bd522 commit c51bd77

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- Properly sanitize the event context and SDK information (#1943)
8+
- Don't send error 429 as `network_error` (#1957)
89

910
## 7.20.0
1011

Sources/Sentry/SentryHttpTransport.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ - (void)sendEnvelope:(SentryEnvelope *)envelope
225225
addRequest:request
226226
completionHandler:^(NSHTTPURLResponse *_Nullable response, NSError *_Nullable error) {
227227
// If the response is not nil we had an internet connection.
228-
if (error) {
228+
if (error && response.statusCode != 429) {
229229
[_self recordLostEventFor:envelope.items];
230230
}
231231

Tests/SentryTests/Networking/SentryHttpTransportTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,19 +287,25 @@ class SentryHttpTransportTests: XCTestCase {
287287
}
288288

289289
func testSendEventWithRetryAfterResponse() {
290+
fixture.requestManager.nextError = NSError(domain: "something", code: 12)
291+
290292
let response = givenRetryAfterResponse()
291293

292294
sendEvent()
293295

294296
assertRateLimitUpdated(response: response)
297+
assertClientReportNotStoredInMemory()
295298
}
296299

297300
func testSendEventWithRateLimitResponse() {
301+
fixture.requestManager.nextError = NSError(domain: "something", code: 12)
302+
298303
let response = givenRateLimitResponse(forCategory: SentryEnvelopeItemTypeSession)
299304

300305
sendEvent()
301306

302307
assertRateLimitUpdated(response: response)
308+
assertClientReportStoredInMemory()
303309
}
304310

305311
func testSendEnvelopeWithRetryAfterResponse() {

0 commit comments

Comments
 (0)