Skip to content

Commit

Permalink
Fix unhandled status resp resulting in bad reqs being sent repeatedly (
Browse files Browse the repository at this point in the history
  • Loading branch information
matux authored Jul 25, 2023
1 parent 9cc4ff6 commit 10b792c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ - (void)recordPostReply:(nullable RollbarPayloadPostReply *)reply
}

switch (reply.statusCode) {
case 401: // unauthorized
case 403: // access denied
case 404: // not found
RBLog(@"\tQueuing record");
//let's hold on on posting to the destination for 1 minute:
// let's hold on on posting to the destination for 1 minute:
self->_nextEarliestPost = [NSDate dateWithTimeIntervalSinceNow:60];
self->_localWindowCount = 0;
self->_serverWindowRemainingCount = 0;
Expand All @@ -113,7 +114,7 @@ - (void)recordPostReply:(nullable RollbarPayloadPostReply *)reply
case 422: // unprocessable entity
default:
RBLog(@"\tDropping record");
self->_nextServerWindowStart = [NSDate dateWithTimeIntervalSinceNow:reply.remainingSeconds];;
self->_nextServerWindowStart = [NSDate dateWithTimeIntervalSinceNow:reply.remainingSeconds];
self->_serverWindowRemainingCount = reply.remainingCount;
if (self->_nextLocalWindowStart) {
self->_localWindowCount = 0;
Expand Down
16 changes: 9 additions & 7 deletions RollbarNotifier/Sources/RollbarNotifier/RollbarThread.m
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,10 @@ - (RollbarTriStateFlag)sendPayload:(nonnull NSData *)payload
switch (reply.statusCode) {
case 200: // OK
return RollbarTriStateFlag_On; // the payload was successfully transmitted
case 400: // bad request
case 413: // request entity too large
case 422: // unprocessable entity
return RollbarTriStateFlag_Off; // unecceptable request/payload - should be dropped
case 401: // unauthorized
case 403: // access denied
case 404: // not found
return RollbarTriStateFlag_None; // worth retrying later
case 429: // too many requests
switch (self.rateLimitBehavior) {
case RollbarRateLimitBehavior_Queue:
Expand All @@ -565,10 +565,12 @@ - (RollbarTriStateFlag)sendPayload:(nonnull NSData *)payload
default:
return RollbarTriStateFlag_Off;
}
case 403: // access denied
case 404: // not found
case 400: // bad request
case 413: // request entity too large
case 422: // unprocessable entity
default:
return RollbarTriStateFlag_None; // worth retrying later
return RollbarTriStateFlag_Off; // unacceptable request/payload - should be dropped

}
}

Expand Down

0 comments on commit 10b792c

Please sign in to comment.