machty / ember-concurrency

ember-concurrency is an Ember Addon that enables you to write concise, worry-free, cancelable, restartable, asynchronous tasks.
http://ember-concurrency.com
MIT License
691 stars 157 forks source link

Ember-concurrency@2: lastRunning field is not cleared when task instance is finished #403

Closed andreyfel closed 3 years ago

andreyfel commented 3 years ago

While migrating to e-c@2 our tests caught a bug: Run a task that eventually fails (a yielded promise got rejected). After that task.lastRunning is not cleared and still points to the last task instance.

maxfierke commented 3 years ago

@andreyfel Could you post a small reproduction?

andreyfel commented 3 years ago

Sure, while I was testing I noticed it won't clean up lastRunning even in the case without rejection:

test('lastRunning', async function(assert) {
  class MyClass {
    @task
    * task() {
      yield timeout(10);
    }
  }

  const myObj = new MyClass();

  await perform(myObj.task);

  assert.strictEqual(taskFor(myObj.task).isRunning, false, 'isRunning is false when task finished running');
  assert.strictEqual(taskFor(myObj.task).lastRunning, null, 'lastRunning is null when task finished running');
});