fix(core): Record client report with reason for HTTP 413 responses#19093
fix(core): Record client report with reason for HTTP 413 responses#19093
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements proper handling for HTTP 413 (Content Too Large) responses from Relay, aligning with the updated SDK specification. When an envelope exceeds size limits, the SDK now records client reports with the send_error discard reason and logs a clear error message for users.
Changes:
- Added 413 status code detection in the base transport's response handler
- Records client reports with
send_errorreason for all envelope items (except client reports themselves to avoid feedback loops) - Logs an informative error message when envelopes are rejected due to size limits
- Ensures 413 responses don't trigger rate limiting behavior (early return before rate limit update)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/transports/base.ts | Added HTTP 413 status code handling with client report recording and error logging, positioned before rate limit updates |
| packages/core/test/lib/transports/base.test.ts | Added comprehensive test suite covering single/multi-item envelopes, client report handling, and no rate limiting verification |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
| // Loss of envelope content is expected so we record a send_error client report | ||
| // https://develop.sentry.dev/sdk/expected-features/#dealing-with-network-failures | ||
| if (response.statusCode === 413) { | ||
| DEBUG_BUILD && |
There was a problem hiding this comment.
super-l: Suggestion for a follow-up: Do you think we could save some bytes here by combining the two debug warns (the one added here and the one below)? I think we could even guard the entire if block in line 87 with DEBUG_BUILD which should shake out some more bytes. We can check that when running size checks in the PR and looking at the non-debug CDN bundles. Feel free to disregard!
There was a problem hiding this comment.
I added a check to treeshake the block down there, but could not refactor the message in a way that saves up some byte, since both messages will get dropped if debug is disabled.
7527529 to
b42a04e
Compare
Implements handling of HTTP 413 (Content Too Large) responses in the base transport according to the updated SDK spec.
send_errordiscard reason for all envelope itemsCloses #18935