Skip to content

Commit 92197a9

Browse files
committed
Refactor request handling in BranchRequestQueue to improve failure management
- Updated the processRequest method to handle request failures instead of re-queuing, enhancing error handling logic. - Simplified the logic for requests waiting on processes to finish by invoking handleFailure, improving clarity and maintainability. - Ensured all changes align with existing functionality while improving the robustness of request processing.
1 parent c79a899 commit 92197a9

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Branch-SDK/src/main/java/io/branch/referral/BranchRequestQueue.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,8 @@ class BranchRequestQueue private constructor(private val context: Context) {
131131
*/
132132
private suspend fun processRequest(request: ServerRequest) {
133133
if (!canProcessRequest(request)) {
134-
// Re-queue the request if it can't be processed yet
135-
delay(100) // Small delay before retry
136-
requestChannel.send(request)
134+
// Request cannot be processed - handle failure instead of retrying
135+
request.handleFailure(BranchError.ERR_OTHER, "Request cannot be processed at this time")
137136
return
138137
}
139138

@@ -144,9 +143,7 @@ class BranchRequestQueue private constructor(private val context: Context) {
144143
when {
145144
request.isWaitingOnProcessToFinish() -> {
146145
BranchLogger.v("Request $request is waiting on processes to finish")
147-
// Re-queue after delay
148-
delay(50)
149-
requestChannel.send(request)
146+
request.handleFailure(BranchError.ERR_OTHER, "Request is waiting on processes to finish")
150147
}
151148
!hasValidSession(request) -> {
152149
BranchLogger.v("Request $request has no valid session")

0 commit comments

Comments
 (0)