Skip to content

Commit 2be9cd7

Browse files
committed
do not discard on 429
1 parent 8ed1dce commit 2be9cd7

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

sentry/src/main/java/io/sentry/transport/AsyncHttpTransport.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,12 @@ public void run() {
309309

310310
options.getLogger().log(SentryLevel.ERROR, message);
311311

312-
if (result.getResponseCode() >= 400) {
312+
// ignore e.g. 429 as we're not the ones actively dropping
313+
if (result.getResponseCode() >= 400 && result.getResponseCode() != 429) {
313314
envelopeCache.discard(envelope);
314-
// ignore e.g. 429 as we're not the ones actively dropping
315-
if (result.getResponseCode() != 429) {
316-
options
317-
.getClientReportRecorder()
318-
.recordLostEnvelope(DiscardReason.NETWORK_ERROR, envelopeWithClientReport);
319-
}
315+
options
316+
.getClientReportRecorder()
317+
.recordLostEnvelope(DiscardReason.NETWORK_ERROR, envelopeWithClientReport);
320318
}
321319

322320
throw new IllegalStateException(message);

sentry/src/test/java/io/sentry/transport/AsyncHttpTransportTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class AsyncHttpTransportTest {
157157
}
158158

159159
@Test
160-
fun `discards envelope after unsuccessful send 429`() {
160+
fun `stores envelope after unsuccessful send 429`() {
161161
// given
162162
val envelope = SentryEnvelope.from(fixture.sentryOptions.serializer, createSession(), null)
163163
whenever(fixture.transportGate.isConnected).thenReturn(true)
@@ -180,7 +180,7 @@ class AsyncHttpTransportTest {
180180
order.verify(fixture.sentryOptions.envelopeDiskCache).storeEnvelope(eq(envelope), anyOrNull())
181181

182182
order.verify(fixture.connection).send(eq(envelope))
183-
order.verify(fixture.sentryOptions.envelopeDiskCache).discard(eq(envelope))
183+
verify(fixture.sentryOptions.envelopeDiskCache, never()).discard(any())
184184
}
185185

186186
@Test

0 commit comments

Comments
 (0)