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:
Juan Tejada 2016-06-09 15:45:11 -07:00
parent 5e6abfbe68
commit da20bcc931
3 changed files with 17 additions and 3 deletions

View file

@ -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) ->

View file

@ -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",

View file

@ -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) {
}