TaskInstance '__DS_COPY_TASK_RUNNER__' was canceled because it belongs to a 'drop' Task that was already running.
Hello.
I am using ember-data-copyable (0.2.1) to copy models, its very cool! And had no problems till today :( when I tried to copy same model in multiple times.
I have Promise.all(promises), in every of that promises I copy one or more models, but those are always the same models for all promises.
For example, I have 3 models (taskAsignments) , and I want copy all 3 of them in for example 6 promises.
What I encounter is, that all 3 models are copied in firstProcessedPromise and will fail in all other (five) promises with message :
TaskCancelation: TaskInstance 'DS_COPY_TASK_RUNNER' was canceled because it belongs to a 'drop' Task that was already running. For more information, see: http://ember-concurrency.com/#/docs/task-cancelation-help
I tried to rewrite Promise.all with reduce, so all 6 promises would be called in synchronized way, but result was same sadly. I also tried deep and not deep .copy with same result.
If possible please advice if have any idea.
I tried to replace .copy with manual (create record + calling all setters) copping and it went with no error. Also tried to get some info from ember slack, here is response, but not sure if it helps :
it’s hard to say without seeing some of the code, but that’s an error that will result from a promise rejection after a task instance has been coerced to a promise (usually by calling .then() or .catch() from a task instance, or by passing the task instance to something like an RSVP.hash or returning it from a route lifecycle hook).
this is mentioned in the docs here: http://ember-concurrency.com/api/global.html#didCancel
I have this issue to when attempting to copy 2+ of the same model at once. Seems to be that only the last scheduled copy is performed all other copies are cancelled with the error outlined above.
Are you guys trying to copy the same model instance multiple times or are you copying different instances of the same model type?
Hi. "same model instance multiple times", yes i get one assigment from database, then run 3 promises in same time and each of them will try to make its own copy of that exact assigment.
Makes sense. The copy task runner has a drop concurrency task policy. That means it will only execute the first request and ignore the rest until it's done running.
I need to investigate other concurrency policies before just removing this one due to unforeseen implications. In the mean time, you guys will need to chain your requests.
async copyModels(model) {
await model.copy();
await model.copy();
await model.copy();
}
I also tried synchronous promises(with reduce), it did not help (and i was sure it will) .
Hmmmm thats pretty odd. I'll investigate this further in the next week or two. Pretty swamped at the moment.
@offirgolan Would you be willing to entertain a PR that makes it possible to allow a configurable set of concurrency options?
Something like:
model.copy({concurrencyPolicy: 'keepLatest'}) //because i can't spell Enqueue
I'm not familiar enough with the guts of EC to understand if you can dynamically apply .drop or whatever, but on the mixin side we could add a different layer of abstraction to do like
[COPY_TASK_<TYPE>]: task(function*() { return this.get('COPY_TASK').perform(options)).<TYPE>()
@donaldwasserman I would if there was a decent way of doing this. I'd rather not bomb the model's proto with a bunch of copy tasks for each concurrency policy.
ping @machty any thoughts on how I can support something like this?
I think we shouldn't enforce any kind of concurrency policy ourselves and leave that choice to the user.
@offirgolan do you recall the reason to set the copy task concurrency policy to drop?