Fix unhandled status responses resulting in bad requests being sent repeatedly #320
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the change
This PR fixes an issue where unhandled server responses were being set for immediate reprocessing and being queued for retry instead of being dropped.
The logic is excessively complicated and it's not easy to explain, so 🐻 with me.
Depending on the server response, we decide either to requeue an occurrence to be sent 60s later (eg. 503), or immediately drop it (eg. 400).
The timing aspect (do it after 60s or immediately), and the decision (drop or queue) are done separately.
A
first, we check the http status response and decide whether we want to reprocess in 60s, or immediately. (yeah)B
then, later on, in an entirely different place, we check the http status response and decide whether we want to drop the request or queue it.The way we were processing unhandled server responses was inverted in first and second. So, during
A
, we'd instruct the request to be reprocessed immediately (cause it has to be dropped), but duringB
, we'd instruct the request to be queued instead of dropped.The result was a failed request that was being resent repeatedly and immediately, forever and ever (because it wasn't being remove from the db either).
Type of change
Related issues
Checklists
Development
Code review