ember.js: Possible 3.15/Octane regression with ember-table addon

We noticed that the release of Ember 3.15 broke the test suite for the Ember Table addon.

The errors we are seeing look like this:

Error: Assertion Failed: You attempted to update `rows` on `<(unknown):ember4815>`,
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.
            
            `rows` was first used:
            
            - While rendering:
              ----------------
                application
                  index
                    ember-table
                      ember-tfoot
                        this.data-test-row-count

We have an issue open at the ember-table repo: https://github.com/Addepar/ember-table/issues/795 And this is a link directly to the breaking build at Travis: https://travis-ci.org/Addepar/ember-table/jobs/623723306

It may be that we are doing something unusual/unsavory in our code to trigger this, but I thought it might be worth raising attention in case it belies a deeper issue worth looking into, since this was only a minor release and our test suite was green with the previous minor release.

Thanks in advance if anyone has any suggestions about where to go hunting for a fix.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

ember-source 3.16.0 has the fix for this. https://github.com/emberjs/ember.js/pull/18668

@pjcarly I needed to add yield Promise.resolve(); as the first statement in the function (in the ember-concurrency task). I can not remember how I found out about this but I think @NullVoxPopuli gave me the tip.

Currently we are on "ember-source": "3.28.1". I don’t know if we can remove the yield Promise.resolve(); already but it works now and I’m happy 🙂

@aarzootrehan this error means that you are using the array during the render process in some way before you attempt to update it. This could result in, for instance, Ember rendering your array before it was updated, and not updating properly, which is why it is not allowed in general.

The recommendation is to avoid doing this, since it requires you to rerender multiple times. It may mean you have to refactor some code to get things to work in a way where your array is mutated before it is used, but this is generally easier to predict code-wise.

If you think that rerendering is acceptable for this use case, then you can opt-in to a second render pass by scheduling into actions:

schedule('actions', () => this.abc.pushObject());

This is generally not recommended, I really do encourage you to try to refactor your code to avoid this, but you can use it as an escape hatch.