fix: Don't retry sending envelopes when getting 4xx or 5xx
Description
The Cocoa and Java SDK retry sending envelopes when getting a 4xx or 5xx HTTP response from the backend. This can lead to a retry loop in some scenarios. For example, if the event payload is too big, Relay returns a 400. Both SDKs will retry sending the envelope until the cache is full, then delete it.
Instead, the SDKs MUST delete the envelope when getting a 4xx or 5xx and record a client report with the reason send_error. But for an HTTP 429 response, SDKs MUST discard the envelope without recording a client report, in compliance with the rate limit rules.
Please double-check if the RN SDK already handles this correctly; if it does, please close the issue with a comment.
Related develop docs PR https://github.com/getsentry/sentry-docs/pull/15571 and Cocoa SDK PR https://github.com/getsentry/sentry-cocoa/pull/6618 and Java issue https://github.com/getsentry/sentry-java/issues/4921
This would probably not need implementation on our side since the React Native SDK uses the native SDKs to send envelopes. I'll leave this open to test that everything is working as expected when the native fixes land.
I also thought so @antonis. If you're sure about this, you can close this, or leave it open until you bumped to the native SDK versions including these fixes. Up to you.
Noting that the native changes have been merged on both iOS and Android. Since the iOS fix will be release in a next 9.x release I'll resolve this issue in our next major (v8).