Retry group sends if any of its errors are re-tryable.
// FREEBIE
This commit is contained in:
parent
f191d6b096
commit
ced9d6f460
|
@ -722,6 +722,9 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
||||||
|
|
||||||
[completionFuture catchDo:^(id failure) {
|
[completionFuture catchDo:^(id failure) {
|
||||||
// failure from toc_thenAll yields an array of failed Futures, rather than the future's failure.
|
// failure from toc_thenAll yields an array of failed Futures, rather than the future's failure.
|
||||||
|
NSError *firstRetryableError = nil;
|
||||||
|
NSError *firstNonRetryableError = nil;
|
||||||
|
|
||||||
if ([failure isKindOfClass:[NSArray class]]) {
|
if ([failure isKindOfClass:[NSArray class]]) {
|
||||||
NSArray *groupSendFutures = (NSArray *)failure;
|
NSArray *groupSendFutures = (NSArray *)failure;
|
||||||
for (TOCFuture *groupSendFuture in groupSendFutures) {
|
for (TOCFuture *groupSendFuture in groupSendFutures) {
|
||||||
|
@ -735,15 +738,28 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
|
||||||
if ([error shouldBeIgnoredForGroups]) {
|
if ([error shouldBeIgnoredForGroups]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return failureHandler(error);
|
|
||||||
|
if ([error isRetryable] && !firstRetryableError) {
|
||||||
|
firstRetryableError = error;
|
||||||
|
} else if (![error isRetryable] && !firstNonRetryableError) {
|
||||||
|
firstNonRetryableError = error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we only received errors that we should ignore,
|
// If any of the group send errors are retryable, we want to retry.
|
||||||
// consider this send a success.
|
// Therefore, prefer to propagate a retryable error.
|
||||||
successHandler();
|
if (firstRetryableError) {
|
||||||
|
return failureHandler(firstRetryableError);
|
||||||
|
} else if (firstNonRetryableError) {
|
||||||
|
return failureHandler(firstNonRetryableError);
|
||||||
|
} else {
|
||||||
|
// If we only received errors that we should ignore,
|
||||||
|
// consider this send a success.
|
||||||
|
successHandler();
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue