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

Doesn't work with async observers #291

Open
jakesjews opened this issue Nov 8, 2019 · 18 comments
Open

Doesn't work with async observers #291

jakesjews opened this issue Nov 8, 2019 · 18 comments

Comments

@jakesjews
Copy link

I recently had to downgrade my applications ember version from 3.13 due to very slow performance from synchronous observers. When I enabled async observers I noticed that ember-awesome-macros were no longer computing correctly. This repo is a fork of ember-macro-helpers which has failing tests from using async observers.

@enspandi
Copy link

We're experiencing same issues. We had just one failing test with "mapBy('...', raw('...))" with "default async observers" disabled. And many more tests failing with "default async observers" enabled.

@kellyselden
Copy link
Owner

A fix is welcome. I don't have the time to dig in.

@enspandi
Copy link

Setting the observers as 'sync' already fixed some issues here:
https://github.com/kellyselden/ember-macro-helpers/blob/master/addon/create-class-computed.js#L54
https://github.com/kellyselden/ember-macro-helpers/blob/master/addon/create-class-computed.js#L126

Like:

... = observer({
  dependentKeys: [mappedKey],
  fn: rewriteComputed,
  sync: true,
});

@enspandi
Copy link

@jakesjews Pushed pr at #307. Maybe you can test your app with that?

@jakesjews
Copy link
Author

@enspandi I tried something similar and it was functional. Unfortunately it's so slow on newer Ember that our application timed out on its load tests. I ended up replacing awesome-macros with regular computed properties.

@ctjhoa
Copy link

ctjhoa commented May 20, 2020

For the record, slow perf on observer was planned in async observer RFC
https://emberjs.github.io/rfcs/0494-async-observers.html#drawbacks

@RobbieTheWagner
Copy link

@enspandi are you using the workaround from your PR? I am curious how bad the perf issues are. @kellyselden any thoughts on if that PR should be accepted or if you had something else in mind? It would be great to unblock people using this addon from being able to update to Octane.

@kellyselden
Copy link
Owner

I'm not sure what the implications of that PR are, but it looks simple enough. If the tests pass and it unblocks people, I don't see a problem with merging it.

@RobbieTheWagner
Copy link

@kellyselden it seems like tests are passing for everything but Ember 3.8. I'm not sure why exactly. I would definitely like to figure out a solution soon, as we are stuck on Ember 3.14 until this is resolved.

@kellyselden
Copy link
Owner

In that case, I think with some ember-cli-update magic, we should be able to drop 3.8 support.

@RobbieTheWagner
Copy link

@kellyselden do you want to make those updates or would you like me to open a PR for that?

@ctjhoa
Copy link

ctjhoa commented Jun 17, 2020

@rwwagner90 FYI, perf are really bad. I'm not even sure this should be considered as a valid fix.
Like @jakesjews we end up replacing awesome-macros with regular computed properties.
We worked on an ember codemod to ease that transition, we probably gonna open source it in a week or 2.

@RobbieTheWagner
Copy link

@ctjhoa definitely interested to see that codemod!

Is there no way to get this to work without making the observers sync? @kellyselden any thoughts here? If it makes things unusable in newer Ember, and there is no better fix, I am not sure how to proceed.

@enspandi
Copy link

enspandi commented Jun 18, 2020

@rwwagner90 Yes, we're using this workaround in production

Our tests suite definitely got slower, but this was in the upgrade from 3.12 to 3.13 - so the cause might not be awesome macros. When using the app we didn't notice a difference 👍 ; Fyi slow test suite was mostly a problem for travis, but locally with running tests in parallel it didn't change much.

But generally we're also slowly transitioning away from computeds and awesome macros and use getters with tracked props. Definitely an improvement with better typescript support as well imo.

@RobbieTheWagner
Copy link

@enspandi yeah, we are working on transitioning to tracked as well, but there are sometimes valid use cases for awesome macros still.

@ctjhoa
Copy link

ctjhoa commented Jun 29, 2020

@rwwagner90 Here is the codemod to replace macros with regular computed properties.
https://github.com/concordnow/ember-macros-codemod
There are some macros missing and some edge cases the codemod cannot deal with but it will help you to do 80-90% of the work.

@RobbieTheWagner
Copy link

@ctjhoa just FYI this codemod did not do anything for me. It only removed imports and did not refactor the computeds.

@ctjhoa
Copy link

ctjhoa commented Jul 29, 2020

@rwwagner90 Please open an issue in ember-macros-codemod repo with reproduction samples.
You have the list of the covered macros here with some examples.

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

No branches or pull requests

5 participants