- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.4k
 
Don't retry tasks when running in foreground #6900
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -61,12 +61,12 @@ class TaskSpecWorker( | |
| 
     | 
||
| try { | ||
| val completed = | ||
| taskSpec.getTask(applicationContext, stringInputData, isLastUniqueExecution(taskSpec)) { isStopped }.get() | ||
| taskSpec.getTask(applicationContext, stringInputData, foreground || isLastUniqueExecution(taskSpec)) { isStopped }.get() | ||
| val maxRetries = taskSpec.maxRetries | ||
| 
     | 
||
| return if (completed) { | ||
| Result.success() | ||
| } else if (maxRetries == null || runAttemptCount < maxRetries) { | ||
| } else if (!foreground && (maxRetries == null || runAttemptCount < maxRetries)) { | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to   | 
||
| Result.retry() | ||
| } else { | ||
| Result.failure() | ||
| 
          
            
          
           | 
    ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -211,7 +211,7 @@ class BlankFormListViewModel( | |
| private const val SYNC_NOTIFICATION_CHANNEL = "form_updates" | ||
| private const val SYNC_NOTIFICATION_CHANNEL_NAME = "Form updates" | ||
| 
     | 
||
| private const val SYNC_NOTIFICATION_ID = 1 | ||
| private const val SYNC_NOTIFICATION_ID = 3 | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like we've made an assumption in the code base that notifications are identified by their ID and their channel. In fact, they are only identified by ID, so this should be unique. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you elaborate on this? Why 3? What was the issue here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
 Yes, this would be important to make it clear. Will that be added to #6902 or a separate issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add that to #6902. Right now it's just failing tests (one of which drives out this change). That PR will be the   | 
||
| 
     | 
||
| private fun getSyncTag(projectId: String): String { | ||
| return "match_exactly_foreground:$projectId" | ||
| 
          
            
          
           | 
    ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should always count a foreground task as the last execution so that jobs like
SyncFormTaskSpecswitch to the behaviour they would use in that mode (like notifying about errors).