Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with Ember v3.22 #553

Closed
josemarluedke opened this issue Oct 8, 2020 · 9 comments · Fixed by #554
Closed

Errors with Ember v3.22 #553

josemarluedke opened this issue Oct 8, 2020 · 9 comments · Fixed by #554

Comments

@josemarluedke
Copy link
Contributor

Just tried upgrading an app to Ember v3.22 and started getting some errors in changeset.

index.js:172 Uncaught (in promise) Error: Assertion Failed: You attempted to update `_changes` on `changeset:[object Object]`, 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.

`_changes` was first used:

The same happens with _errors as well.

image

Version

changeset v 3.8.2 (also tested with latest version but same occurs. )
ember v 3.22

snewcomer added a commit that referenced this issue Oct 10, 2020
snewcomer added a commit that referenced this issue Oct 10, 2020
* [Deps]: bump 3.22

close #553

* Add a bit more to the save catch test
@snewcomer
Copy link
Collaborator

@josemarluedke Happen to know if it tracks back to your codebase or do all signs point to this addon?

I certainly have seen this many times and I know work has been done in emberjs to address some of these things. Also here is an ember-data issue with similar problems (only in development). There is still one PR to land below as well.

emberjs/data#7196
glimmerjs/glimmer-vm#1111

@josemarluedke
Copy link
Contributor Author

@snewcomer I apologize. You are right, the issues were not in the addon itself, but rather how I was interacting with it.

I had two main issues:

  1. I was calling changeset.set on my component constructor.
  2. I was calling validate twice in the same time, I guess. See PR: Delay calling validate on changeset form input to avoid errors josemarluedke/frontile#96

I do wonder if the second issue could be avoided somehow in the addon?

Thanks for quickly confirming that there were no issues in the addon.

@snewcomer
Copy link
Collaborator

It is an interesting question. I can see both sides. I might lean one way though. Since these errors can be triggered with an infinite number of user land examples and is a necessity in protecting data integrity, my feeling is it should always be on the user. We might be chasing our tail if any data mutation hook needed to protect against this scenario.

@snewcomer
Copy link
Collaborator

FYI -

emberjs/ember.js#19192

@ijlee2
Copy link

ijlee2 commented Nov 11, 2020

Hi, @snewcomer. After upgrading ember-source from v3.22.0 to v3.22.1 in my app, I'm still encountering the error message when I press the Enter key to save a changeset.

You attempted to update `_errors` on `changeset:[object Object]`, 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.

In order for this message to go away, would ember-changeset or ember-changeset-validations itself need to use ember-source v3.22.1 (i.e. would a new release be needed)?

@ijlee2
Copy link

ijlee2 commented Nov 13, 2020

@snewcomer I realized that the error was my fault, my apologies.

I was updating the changeset on an input's focusout event as well as Enter key press. When I submitted the input by pressing Enter and made a route transition afterwards, the input field lost focus, triggering the focusout event. I believe this caused the changeset to update twice instead of once.

@sinankeskin
Copy link

sinankeskin commented Aug 28, 2021

Hi everyone.

I'm trying to upgrade one of our app to Ember v3.22 and seeing a lot of this deprecations. I'm just creating a changeset and setting value to a property.

What's the best way to avoid this? @snewcomer

DEPRECATION: You attempted to update _changesonchangeset:[object Object], 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.

Thanks.

@snewcomer
Copy link
Collaborator

@sinankeskin 👋 This is similar to this case. You might have to adjust when/how the changes is created then updated. The problem is something was read-then-written in the same computation in the same "tick".

#602

@sinankeskin
Copy link

@sinankeskin 👋 This is similar to this case. You might have to adjust when/how the changes is created then updated. The problem is something was read-then-written in the same computation in the same "tick".

#602

I've fixed this with a creating middle classes. Works perfect now. Thanks a lot @snewcomer Appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants