mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-23 07:36:12 +08:00
fix(plugins):Call NotifyPlugins task regardless of metadata sync success
- Before this commit, if any SyncbackMetadataTask for a message failed, we would never run NotifyPluginsOfSendTask because of the dependency in place. This caused unintended consequences like open/link tracking not working if any other plugin failed to syncback metadata, despite the tracking metadata having been saved successfuly. - This commit makes it so NotifyPluginsOfSendTask always runs after the SyncbackMetadata tasks regardless of wether they fail or succeed by updating the task queue to support this dependency scenario
This commit is contained in:
parent
5e6abfbe68
commit
da20bcc931
3 changed files with 17 additions and 3 deletions
|
@ -247,7 +247,7 @@ class TaskQueue
|
|||
|
||||
# Recursively notifies tasks of dependent errors
|
||||
_notifyOfDependentError: (failedTask, err) ->
|
||||
downstream = @_tasksDependingOn(failedTask) ? []
|
||||
downstream = @_tasksToDequeueOnFailure(failedTask) ? []
|
||||
Promise.map downstream, (downstreamTask) =>
|
||||
|
||||
return Promise.resolve(null) unless downstreamTask
|
||||
|
@ -280,9 +280,11 @@ class TaskQueue
|
|||
otherTask.queueState.debugStatus = Task.DebugStatus.DequeuedObsolete
|
||||
@dequeue(otherTask)
|
||||
|
||||
_tasksDependingOn: (task) ->
|
||||
_tasksToDequeueOnFailure: (failedTask) ->
|
||||
_.filter @_queue, (otherTask) ->
|
||||
task isnt otherTask and otherTask.isDependentOnTask(task)
|
||||
failedTask isnt otherTask and
|
||||
otherTask.isDependentOnTask(failedTask) and
|
||||
otherTask.shouldBeDequeuedOnDependencyFailure()
|
||||
|
||||
_taskIsBlocked: (task) =>
|
||||
_.any @_queue, (otherTask) ->
|
||||
|
|
|
@ -62,6 +62,10 @@ Any plugins you used in your sent message will not be available.`
|
|||
return (other instanceof SyncbackMetadataTask) && (other.clientId === this.messageClientId)
|
||||
}
|
||||
|
||||
shouldBeDequeuedOnDependencyFailure() {
|
||||
return false
|
||||
}
|
||||
|
||||
performLocal() {
|
||||
this.validateRequiredFields([
|
||||
"messageId",
|
||||
|
|
|
@ -513,6 +513,14 @@ export default class Task {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Public: determines if the current task should be dequeued if one of the
|
||||
// tasks it depends on fails.
|
||||
//
|
||||
// Returns `true` (should dequeue) or `false` (should not dequeue)
|
||||
shouldBeDequeuedOnDependencyFailure() {
|
||||
return true;
|
||||
}
|
||||
|
||||
onDependentTaskError(other, error) {
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue