-
Notifications
You must be signed in to change notification settings - Fork 376
Fix: ANR on POST to Outcomes endpoint #2371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
} catch (ex: BackendException) { | ||
Logging.warn( | ||
"""OutcomeEventsController.sendSavedOutcomeEvent: Sending outcome with name: ${event.outcomeId} failed with status code: ${ex.statusCode} and response: ${ex.response} | ||
if (ex.statusCode == HttpURLConnection.HTTP_BAD_REQUEST) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about using our existing NetworkUtils infrastructure? To drop this for any non-RETRYABLE response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the backend is adding this to the header OneSignal-Retry-Limit
Line 313 in 8116c60
private fun retryLimitFromResponse(con: HttpURLConnection): Int? { |
I am wondering if its better to add some logic on the backend that if its a 400 (bad request - which is a client error) then set the retry limit to 0?
I can't think of any reason why a 400 should have a retry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about using our existing NetworkUtils infrastructure? To drop this for any non-RETRYABLE response
Good point, retrying is now only for retryable response. Omitting outcome event for any other error.
c71d30d
to
b657f4b
Compare
For manual testing, did you compare with the current behavior?
I'm seeing even without this PR, those 400 requests are not retried on new session or new cold start. |
Description
One Line Summary
Prevent retrying 400 errors during cold start and clean up any previously saved bad records on device.
Details
Motivation
400 responses are client-side errors that will never succeed on retry. Currently, these can trigger retries during cold start, wasting resources and delaying initialization. In addition, if invalid/bad records were already persisted locally, the SDK would attempt to re-use them, leading to repeated failures.
Scope
Testing
Unit testing
Added/updated unit tests to cover:
Manual testing
Environment: OneSignal example app, Pixel emulator API 33, debug build.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is