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
690 stars 157 forks source link

Issue with `performCount` on Ember v3.15 #337

Closed Turbo87 closed 4 years ago

Turbo87 commented 4 years ago

We tried to update our app to Ember 3.15 this morning and the test suite of one of our apps uncovered the following issue:

Assertion Failed: You attempted to update performCount on <(unknown):ember22520>, but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.

performCount was first used:

  • While rendering: (instance of a (unknown function) modifier)

Stack trace for the first usage: at get (http://localhost:7357/assets/vendor.js:39430:11) at Class.incrementProperty (http://localhost:7357/assets/vendor.js:53987:72) at Class.schedule (http://localhost:7357/assets/vendor.js:158913:12) at Class._performShared (http://localhost:7357/assets/vendor.js:160316:23) at Class.perform (http://localhost:7357/assets/vendor.js:160286:19) at XValidatedInput._focus (http://localhost:7357/assets/vendor.js:143177:33) at XValidatedInput.focusIn (http://localhost:7357/assets/vendor.js:143157:12) at XValidatedInput.trigger (http://localhost:7357/assets/vendor.js:59364:23)

I haven't been able to come up with a reproduction yet, but I'll update this issue if I can provide one.

maxfierke commented 4 years ago

Seems to be triggered by this: https://github.com/machty/ember-concurrency/blob/a863f4172fca5a63104054ff7a7aa41796a41380/addon/-scheduler.js#L54

Mind giving this branch a try: https://github.com/machty/ember-concurrency/pull/338 ?

robclancy commented 4 years ago

I been seeing this issue too.

robclancy commented 4 years ago

That branch fixes it, I have to use it now or can't release.

maxfierke commented 4 years ago

I'm having issues with the test for the fix for it on earlier Ember versions in the CI matrix, but I'll try to fix that up tonight and tag a release. I do not recommend using a branch in production.

Turbo87 commented 4 years ago

@maxfierke it might be possible to remove the test file from the broccoli tree depending on the ember version, but I have to admit that I'm not sure how exactly to do that either 😅

robclancy commented 4 years ago

I mean.. I can't not use the branch it literally breaks everything.

Turbo87 commented 4 years ago

that double negation is hard to parse 😅

allthesignals commented 4 years ago

I'm seeing something similar: image

It's on "numQueued".

Versions:

    "ember-concurrency": "^1.1.5",
    "ember-concurrency-decorators": "^1.0.0",

code:

export default class FindModalSplit extends Helper {
  /**
   * Task that wraps async call to get modal-split record from store
   */
  @task *findModalSplitTask(geoid) {
    return yield [
      this.readonlyStore.find('ACS-modal-split', geoid),
      this.readonlyStore.find('CTPP-modal-split', geoid),
    ];
  }

  /**
   * Main helper 'compute' function
   */
  compute(params) {
    const [geoid] = params;
    if (!geoid) return null;
    return this.findModalSplitTask.perform(geoid);
  }
}
maxfierke commented 4 years ago

@allthesignals can you confirm there are no addons depending on earlier versions of ember-concurrency that might be getting used instead?

allthesignals commented 4 years ago

@maxfierke that was totally it! time to add https://github.com/salsify/ember-cli-dependency-lint to this project...

appreciate it :)