Attachments are dropped at 20 MiB uncompressed even when the compressed request fits Sentry's limits
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- C#
- スター
- 775
- フォーク
- 262
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 118
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-dotnet のほかの issue
-
chore: remove stale IL3050/IL3053 workaround from the iOS sample対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンState: Needs Discussion
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
getsentry/sentry-dotnet#6071 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Heap dumps: every SDK shutdown logs "Error waiting for GarbageCollectionMonitor task to complete"対応中かも @pcbeingused33 が今日担当しました。 オープンState: Needs Discussion
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
getsentry/sentry-dotnet#6039 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
.NET Platform: Android Task
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
getsentry/sentry-dotnet#6020 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Move the Blazor WebAssembly sample off the deprecated DevServer対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン.NET Framework: Blazor
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
getsentry/sentry-dotnet#5906 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Docs MSBuild Needs Docs Update
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
getsentry/sentry-dotnet#5691 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
getsentry/sentry-dotnet の issue をすべて見る
似ている issue
-
[Bug]: Native build script prints a traceback when Git is missing from PATH対応中かも @Jaisuryan-web が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
KnifeLemon/Filee#1953 ·
メンテナーはふだん 1 日以内に返信
-
blazor dotnet easy first-contributor first-contributors good first issue help wanted up-for-grabs
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
fork-commit-merge/fork-commit-merge#8691 ·
メンテナーはふだん 1 日以内に返信
-
bug effort:S P1
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
nightscout/nocturne#4821 ·
メンテナーはふだん 1 日以内に返信
-
Audit by ear: boss warnings, other not-enough messages, ailments and barriers in a chapter 1 battleオープンenhancement needs-game ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Sour-Dev-Home/metaphor-accessibility#1273 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
joinrpg/joinrpg-net#6336 ·
メンテナーはふだん 1 日以内に返信