Android: a cached envelope is deleted when its resend outlasts flushTimeoutMillis, so a slow or hung connection loses the crash report

Đang mở
#6,195 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
android, java
Lĩnh vực
mobile

Hướng nghiên cứu

Start with EnvelopeSender.java around the processFile logic cited in the issue, then compare its waitFlush() behavior with the 4000 ms setting in AndroidOptionsInitializer. Trace how a send failure marks an envelope for retry and how the crash handler waits for storage. Done means a slow or hung send does not cause the cached crash report to be lost; the reproduction steps provide a way to verify this.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Platform: Android Platform: Java
Description

On Android, a cached envelope (for example, a crash stored on the previous launch) is deleted before its resend has finished, when that resend takes longer than flushTimeoutMillis. The envelope is then never sent.

EnvelopeSender.processFile captures the cached envelope and waits flushable.waitFlush(), which is flushTimeoutMillis: 4000 ms on Android, set in AndroidOptionsInitializer (see #2732). It then deletes the file unless the transport has already marked the envelope for retry (EnvelopeSender.java, around L91–98). The transport marks retry only when the send fails with an IOException. With the default connectionTimeoutMillis and readTimeoutMillis of 30 000 ms, a hung connection fails at about 30 s.

So any resend that takes more than about 4 s loses the race. The file is deleted at about 4 s, and when the IOException arrives the in-memory envelope is not stored again.

There is a related case with the same cause. A Java crash captured while an earlier send is hung on the transport's single thread is never written to disk, because the crash handler waits only flushTimeoutMillis for it to be stored.

Steps to reproduce
  1. Use an Android app on sentry-android 8.31.0. We reproduced it with a plain @sentry/react-native 7.11.0 setup, where the native SDK is initialised once, from JS. The code path is the same on 8.58.0 / main.
  2. Crash the app (adb shell am crash <package>), so the event is cached.
  3. Before relaunching, make the ingest host unreachable without losing connectivity. On an emulator: adb root, then adb shell iptables -I OUTPUT -d <ingest-ip> -j DROP.
  4. Launch and wait at least 5 s. About 4 s after init, the cached envelope disappears from cache/sentry/<hash>/.
  5. Remove the rule and relaunch. The crash never arrives in Sentry.

With the network open, the same crash arrives. On a Pixel 6 emulator (API 35), every blocked run lost the report and every open run delivered it.

Expected result

A cached envelope whose send has not completed is kept for a later retry instead of being deleted when the flush wait expires. Alternatively, the flush wait for cached sends and the connection/read timeouts are reconciled, so a failed send is marked retryable before the file can be deleted.

Actual result

The crash report is lost.

Versions

sentry-android 8.31.0 (via @sentry/react-native 7.11.0); source checked on 8.58.0.

Ngôn ngữ chính
Kotlin
Star
1.4k
Fork
483
Merge trung bình
2 ngày 2 giờ
Pull request đã merge (30 ngày)
202

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của getsentry/sentry-java

Tất cả issue của getsentry/sentry-java

Issue tương tự

Thêm issue về Kotlin

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.