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

Explicitly import key-value-store as a service #16619

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wagenet
Copy link

@wagenet wagenet commented May 3, 2022

Ember 3.26 introduces the deprecation detailed in RFC 680. Part of the implementation of this deprecation is switching the injection to a "get-only" property. However, Discourse relies on overwriting the injected value in some places which will now error due to the lack of a setter. The appropriate long-term solution here is to stop using app.inject.

In the short term, we can work around the issue by no longer injecting the keyValueStore, instead looking at each place it is used and defining it as a service there. Since the inject/service method from @ember/service prefixes with the service: namespace, we also have to change how the keyValueStore is registered in the fist place.

This appears to work as expected, however it is possible that it could cause issues for any Discourse plugins that rely on either the auto-injection or the specific name of key-value-store:main in the registry. I'm not sure if this is actually an issue in practice.

@CLAassistant
Copy link

@CLAassistant CLAassistant commented May 3, 2022

CLA assistant check
All committers have signed the CLA.

@wagenet wagenet mentioned this pull request May 3, 2022
@pmusaraj pmusaraj requested review from CvX and hnb-ku May 4, 2022
@pmusaraj
Copy link
Contributor

@pmusaraj pmusaraj commented May 4, 2022

Thanks @wagenet, looks like CI failures are legitimate, not sure whether you have visibility there, but here is a snippet:

not ok 1031 Chrome 101.0 - [118 ms] - Exam Partition 3 - Acceptance: Composer: Shows duplicate_link notice
    ---
        actual: >
            null
        stack: >
            Error: Assertion Failed: You attempted to update <(unknown):ember78082>.keyValueStore to "[object Object]", but it is being tracked by a tracking context, such as a template, computed property, or observer. In order to make sure the context updates properly, you must invalidate the property when updating it. You can mark the property as `@tracked`, or use `@ember/object#set` to do this.

@wagenet
Copy link
Author

@wagenet wagenet commented May 5, 2022

I extracted this out of the context of other Ember upgrades so it looks like it may not work so well with 3.15. I'll investigate further. We may not want to merge this just yet.

@davidtaylorhq davidtaylorhq added the ember-upgrade label Jun 17, 2022
@nattsw
Copy link
Contributor

@nattsw nattsw commented Jun 28, 2022

We may not want to merge this just yet

Is this still true? Otherwise would be good to convert to draft.

Also, you may want to rebase just so you won't have to make too many changes to this branch in the near future.

@wagenet
Copy link
Author

@wagenet wagenet commented Jun 28, 2022

@nattsw I just rebased it. If someone can approve the workflow I can see if it still fails and try to resolve it.

@wagenet wagenet marked this pull request as draft Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ember-upgrade
5 participants