Attachments are dropped at 20 MiB uncompressed even when the compressed request fits Sentry's limits
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ó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start with the referenced paths in src/Sentry/Internal/Http/HttpTransportBase.cs, CachingTransport.cs, and GzipBufferedRequestBodyHandler.cs, then trace how rejected envelopes are handled and how client reports record dropped attachments. Compare the retry behavior with the heap dump file deletion ordering described in #5481. Done means rejected uploads retry once with the event but no attachments, record attachment drops, and work for buffered, streamed, uncompressed, and cached requests.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Before sending, the SDK drops any attachment whose uncompressed size is over MaxAttachmentSize (20 MiB by default). Sentry's ingestion limits are now higher, and they're measured differently:
- at most 40 MB per compressed request;
- at most 200 MB of uncompressed attachments per event (docs).
So the SDK drops attachments that Sentry would accept. Heap dumps hit this the hardest (#4007). In a repro on main, a 59 MB .gcdump gzipped to 13.6 MB, well within the 40 MB request limit, but the SDK still dropped it.
When the SDK drops an attachment, the only sign is a warning in the SDK's own diagnostic log. The event has no marker, and no client report is recorded (HttpTransportBase.cs#L149-L160). For heap dumps, main also deletes the file afterwards (#5481), so the dump is gone with no trace in Sentry.
The server limits have already changed once without the SDK following. Whatever we do here shouldn't leave us in the same position the next time they change.
What happens when the server says no
If a request is over the server's limits, the server rejects the whole envelope, event included:
- A
413goes throughHandleFailure, which records every item in the envelope as asend_errordiscard and resends nothing (HttpTransportBase.cs#L347-L349, #L494-L505). - For a streamed request, the server doesn't wait for the whole body. It resets the connection once the limit is passed, which shows up as a broken pipe (CachingTransport.cs#L310-L316).
So "just raise MaxAttachmentSize" isn't enough on its own. An attachment that's too big would then take its event down with it.
Option A: check the server's limits in the SDK
Check both limits at the point where each size is known:
- Uncompressed: the envelope's attachments must total ≤ 200 MB. This is known before serialization.
- Compressed: the request must be ≤ 40 MB. With the default
GzipBufferedRequestBodyHandler, the whole compressed body is already in aMemoryStream, so its exact length is known before the request goes out (GzipBufferedRequestBodyHandler.cs#L45-L60). If it's over, drop the attachments and send the event without them.
Downsides:
- The SDK hardcodes the server's numbers, so this goes stale the next time they change, exactly as the 20 MiB default did.
- It only covers the buffered default.
RequestBodyCompressionBuffered = falsestreams the body, so the compressed size isn't known until it has been sent, and only the 200 MB check is possible. A 150 MB attachment passes that check, and if it compresses to over 40 MB, the server rejects the whole request, event included.NoCompressionneeds its own rule as well.
Option B (recommended): let the server decide, and retry without attachments
Send the event with its attachments as normal. If the server rejects the request (a 413, or the connection reset mid-upload), remove the attachments, resend the event once, and record a client report for the dropped attachments (DataCategory.Attachment).
The server stays the only authority on its own limits, so:
- the SDK hardcodes no server numbers, and nothing breaks when the limits change again;
- it works the same for buffered, streamed and uncompressed requests;
- the event always gets through, which is the part worth keeping for heap dumps (see the discussion in #4007).
Costs:
- Wasted upload when a request is rejected: up to the point where the server cuts it off, roughly 40 MB compressed.
- The retry removes every attachment. A
413doesn't say which item was too big. - Ordering. The resent event doesn't need the dump file, but heap dump files are deleted on close (#5481), so the retry has to be decided before that deletion, or the deletion has to come after it.
- Offline caching.
CachingTransportalready treats a broken pipe as a server rejection. The retry has to fit in there, so that a cached envelope that's too big is resent as event-only and not dropped.
I recommend B as the permanent fix. It solves the problem once, where A has to be revisited every time the server changes.
Either way
MaxAttachmentSizestays. The attachments spec says SDKs MUST discard items larger than it. It's a cap the user sets on what they're willing to send (bandwidth, cost), not a copy of the server's limit. Its default is what blocks heap dumps today, so we still need to decide whether to raise the default or to exempt heap dumps. Heap dumps are already an explicit, experimental opt-in.- Fix the doc comment.
MaxAttachmentSizestill says attachments are "limited to 20mb (compressed) on Relay" (SentryOptions.cs#L1232-L1239). It shouldn't quote server numbers at all. - Make drops visible. Record a client report whenever an attachment is dropped, whether by
MaxAttachmentSizeor by a retry. Telling the user on the event itself (for example, a context with the file name and size) would help more, but after a rejection the event is already serialized, so that means rebuilding it for the retry.
Out of scope
Attachments that can never fit in an envelope. Those need the experimental resumable-upload path described in #4007, and that's a separate piece of work.
Relates to #4007
- Ngôn ngữ chính
- C#
- Star
- 775
- Fork
- 262
- Merge trung bình
- 1 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 118
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của getsentry/sentry-dotnet
-
chore: remove stale IL3050/IL3053 workaround from the iOS sampleCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởState: Needs Discussion
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
getsentry/sentry-dotnet#6071 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Heap dumps: every SDK shutdown logs "Error waiting for GarbageCollectionMonitor task to complete"Có thể đã có người làm @pcbeingused33 đã nhận hôm nay. Đang mởState: Needs Discussion
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
getsentry/sentry-dotnet#6039 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
.NET Platform: Android Task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
getsentry/sentry-dotnet#6020 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Move the Blazor WebAssembly sample off the deprecated DevServerCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở.NET Framework: Blazor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
getsentry/sentry-dotnet#5906 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Docs MSBuild Needs Docs Update
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
getsentry/sentry-dotnet#5691 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của getsentry/sentry-dotnet
Issue tương tự
-
In-car displays show 0 km/h and P while the AV drivesCó thể đã có người làm @bazilinskyy đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
bazilinskyy/coupled-sim#366 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
BaryoDev/umbraco-pwa#196 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
microsoft/fluentui-blazor#5688 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug flaky lsp-transport small
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày