Description:
Currently, within the FLW-Mobile-App codebase, several repository classes contain network calls that catch a SocketTimeoutException and recursively call themselves to retry the fetch. Because there is no limit or counter on this recursion, a persistent network timeout will trigger an infinite loop, ultimately crashing the mobile application with a StackOverflowError.
Affected Files & Functions (in FLW-Mobile-App):
IncentiveRepo.kt -> pullAndSaveAllIncentiveActivities()
IncentiveRepo.kt -> pullAndSaveAllIncentiveRecords()
Expected Behavior:
The application should attempt to retry a failed network call a reasonable number of times (e.g., 3 attempts) before failing gracefully and returning an error state to the UI. This prevents memory exhaustion and fatal crashes for field workers with poor connectivity.
Suggested Fix:
Modify the function signatures to include a default parameter retryCount: Int = 3. Inside the catch (e: SocketTimeoutException) block, check if retryCount > 0. If true, make the recursive call passing retryCount - 1. If false, return a default failure value (like false or -1) or emit an error state.
Description:
Currently, within the
FLW-Mobile-Appcodebase, several repository classes contain network calls that catch aSocketTimeoutExceptionand recursively call themselves to retry the fetch. Because there is no limit or counter on this recursion, a persistent network timeout will trigger an infinite loop, ultimately crashing the mobile application with aStackOverflowError.Affected Files & Functions (in
FLW-Mobile-App):IncentiveRepo.kt->pullAndSaveAllIncentiveActivities()IncentiveRepo.kt->pullAndSaveAllIncentiveRecords()Expected Behavior:
The application should attempt to retry a failed network call a reasonable number of times (e.g., 3 attempts) before failing gracefully and returning an error state to the UI. This prevents memory exhaustion and fatal crashes for field workers with poor connectivity.
Suggested Fix:
Modify the function signatures to include a default parameter
retryCount: Int = 3. Inside thecatch (e: SocketTimeoutException)block, check ifretryCount > 0. If true, make the recursive call passingretryCount - 1. If false, return a default failure value (likefalseor-1) or emit an error state.