Skip to content
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

[Fix]Handle incorrect 404 responses; add a delay after creates and retries on 404 of new ids #2059

Merged
merged 6 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
only consider retrying on 404, don't include 410
If the backend returns 410 then it indicates it knows it existed at one
point and it is deleted now. Where a 404 is more abstract.
  • Loading branch information
jkasten2 committed Apr 19, 2024
commit a9dfc0933993563fe40d860bea744aef630c82cf
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal class IdentityOperationExecutor(
NetworkUtils.ResponseStatusType.UNAUTHORIZED ->
ExecutionResponse(ExecutionResult.FAIL_UNAUTHORIZED)
NetworkUtils.ResponseStatusType.MISSING -> {
if (_newRecordState.isInMissingRetryWindow(lastOperation.onesignalId)) {
if (ex.statusCode == 404 && _newRecordState.isInMissingRetryWindow(lastOperation.onesignalId)) {
return ExecutionResponse(ExecutionResult.FAIL_RETRY)
jinliu9508 marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down Expand Up @@ -109,7 +109,7 @@ internal class IdentityOperationExecutor(
NetworkUtils.ResponseStatusType.UNAUTHORIZED ->
ExecutionResponse(ExecutionResult.FAIL_UNAUTHORIZED)
NetworkUtils.ResponseStatusType.MISSING -> {
return if (_newRecordState.isInMissingRetryWindow(lastOperation.onesignalId)) {
return if (ex.statusCode == 404 && _newRecordState.isInMissingRetryWindow(lastOperation.onesignalId)) {
ExecutionResponse(ExecutionResult.FAIL_RETRY)
} else {
// This means either the User or the Alias was already
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ internal class RefreshUserOperationExecutor(
NetworkUtils.ResponseStatusType.UNAUTHORIZED ->
ExecutionResponse(ExecutionResult.FAIL_UNAUTHORIZED)
NetworkUtils.ResponseStatusType.MISSING -> {
if (_newRecordState.isInMissingRetryWindow(op.onesignalId)) {
if (ex.statusCode == 404 && _newRecordState.isInMissingRetryWindow(op.onesignalId)) {
return ExecutionResponse(ExecutionResult.FAIL_RETRY)
}
val operations = _buildUserService.getRebuildOperationsIfCurrentUser(op.appId, op.onesignalId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ internal class SubscriptionOperationExecutor(
NetworkUtils.ResponseStatusType.UNAUTHORIZED ->
ExecutionResponse(ExecutionResult.FAIL_UNAUTHORIZED)
NetworkUtils.ResponseStatusType.MISSING -> {
if (_newRecordState.isInMissingRetryWindow(createOperation.onesignalId)) {
if (ex.statusCode == 404 && _newRecordState.isInMissingRetryWindow(createOperation.onesignalId)) {
return ExecutionResponse(ExecutionResult.FAIL_RETRY)
}
val operations = _buildUserService.getRebuildOperationsIfCurrentUser(createOperation.appId, createOperation.onesignalId)
Expand Down Expand Up @@ -183,7 +183,8 @@ internal class SubscriptionOperationExecutor(
NetworkUtils.ResponseStatusType.RETRYABLE ->
ExecutionResponse(ExecutionResult.FAIL_RETRY)
NetworkUtils.ResponseStatusType.MISSING -> {
if (listOf(
if (ex.statusCode == 404 &&
listOf(
lastOperation.onesignalId,
lastOperation.subscriptionId,
).any { _newRecordState.isInMissingRetryWindow(it) }
Expand Down Expand Up @@ -262,7 +263,12 @@ internal class SubscriptionOperationExecutor(

return when (responseType) {
NetworkUtils.ResponseStatusType.MISSING -> {
if (listOf(op.onesignalId, op.subscriptionId).any { _newRecordState.isInMissingRetryWindow(it) }) {
if (ex.statusCode == 404 &&
listOf(
op.onesignalId,
op.subscriptionId,
).any { _newRecordState.isInMissingRetryWindow(it) }
) {
ExecutionResponse(ExecutionResult.FAIL_RETRY)
} else {
// if the subscription is missing, we are good!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ internal class UpdateUserOperationExecutor(
NetworkUtils.ResponseStatusType.UNAUTHORIZED ->
ExecutionResponse(ExecutionResult.FAIL_UNAUTHORIZED)
NetworkUtils.ResponseStatusType.MISSING -> {
if (_newRecordState.isInMissingRetryWindow(onesignalId)) {
if (ex.statusCode == 404 && _newRecordState.isInMissingRetryWindow(onesignalId)) {
return ExecutionResponse(ExecutionResult.FAIL_RETRY)
}
val operations = _buildUserService.getRebuildOperationsIfCurrentUser(appId, onesignalId)
Expand Down
Loading