Skip to content

Cannot destructure property 'manager' of '.for' as it is undefined. #20708

Closed

Description

@amk221

🔬 Minimal Reproduction

Minimal reproduction of an error in ember-modifier

 Cannot destructure property 'manager' of '.for' as it is undefined.

amk221/-ember-modifier-manager@a3765c5#diff-91d02793f5c4fd5e02a401c33509cafcb6fc7613aef16d97afe18f4b4a080d5cR18-R20

🌍 Environment

  • Ember: - 5.8
  • Ember-CLI: -
  • Node.js/npm: -
  • OS: -
  • Browser: -

Activity

  1. NullVoxPopuli commented on Jun 20, 2024

    @NullVoxPopuli
    SponsorContributor

    Does the issue appear in

    • ember-source 5.9?
    • gjs?

    Thanks!

  2. amk221 commented on Jun 20, 2024

    @amk221
    Author

    ember-source 5.9 = yes, still occurs

    gjs = yes, it still occurs in our app, which is gjs with the original error as above. But, in terms of focusing on the minimal reproduction, no, it instead outputs:

    Attempted to set the same type of manager multiple times on a value. You can only associate one manager of each type with a given value. Value was (unknown function)
    
  3. NullVoxPopuli commented on Jun 20, 2024

    @NullVoxPopuli
    SponsorContributor

    That second error seems like the deps got messed up. Does using pnpm reproduce nhe original error?

  4. amk221 commented on Jun 20, 2024

    @amk221
    Author

    relooking

  5. amk221 commented on Jun 20, 2024

    @amk221
    Author
  6. NullVoxPopuli commented on Jun 20, 2024

    @NullVoxPopuli
    SponsorContributor

    In the gjs branch, there was an issue.
    the modifier import was shadowing the keyword.

    After the fix (amk221/-ember-modifier-manager#1), the new error is

    Uncaught (in promise) TypeError: scheduledUpdateModifiers[Symbol.iterator]().next().value is undefined
        commit runtime.js:3904
        commit runtime.js:3972
        inTransaction runtime.js:3991
        Ember 3
        invoke backburner.js.js:272
        flush backburner.js.js:188
        flush backburner.js.js:344
        _end backburner.js.js:773
        _boundAutorunEnd backburner.js.js:509
        promise callback*buildNext/< backburner.js.js:26
        flush Ember
    

    which is another issue 🤔

  7. NullVoxPopuli commented on Jun 20, 2024

    @NullVoxPopuli
    SponsorContributor
  8. NullVoxPopuli commented on Jun 20, 2024

    @NullVoxPopuli
    SponsorContributor

    ah, no the repro has a problem

  9. NullVoxPopuli commented on Jun 20, 2024

    @NullVoxPopuli
    SponsorContributor

    Here is the fix:

    • don't have two click listeners changing data for the modifier at the same time
    diff --git a/app/components/foo.gjs b/app/components/foo.gjs
    index 2dd2640..56f7ba3 100644
    --- a/app/components/foo.gjs
    +++ b/app/components/foo.gjs
    @@ -23,12 +23,7 @@ export default class Foo extends Component {
       close() {
         console.log("close");
         this.isOpen = false;
    -  }
    -
    -  @action
    -  setValue(value) {
    -    console.log("setValue");
    -    this.value = value;
    +    this.value = "foo";
       }
     
       <template>
    @@ -44,7 +39,6 @@ export default class Foo extends Component {
           type="button"
           class="close"
           {{on "click" this.close}}
    -      {{on "click" (fn this.setValue "foo")}}
         >
           Close
         </button>

    Now... should it work? probably.
    why doesn't it work? idk.

    maybe @chancancode can provide some insights there.

  10. amk221 commented on Jun 20, 2024

    @amk221
    Author

    Thanks for looking!

    I don't think it's the fact that it uses two click handlers, rather, that it updates another tracked property that is an argument to the modifier? Since, you can combine the click handler and the error still happens.

    Anyway, I really would like this to work of course, since the code is 'valid' also don't forget this is an unrealistic minimal production and in reality, one might not be in control to be able to do your suggested fix

  11. NullVoxPopuli commented on Jun 20, 2024

    @NullVoxPopuli
    SponsorContributor

    Since, you can combine the click handler and the error still happens.

    that's not what happens in my PR to your repro 🤔

    Anyway, I really would like this to work of course

    yeah, the fact it doesn't work does seem bad

  12. betocantu93 commented on Jun 28, 2024

    @betocantu93
    Contributor

    Im also having this error with ember-focus-trap

    Attempted to set the same type of manager multiple times on a value. You can only associate one manager of each type with a given value. Value was (unknown function)

    But with FocusTrapModifier, while on host app using ember-eui components

  13. amk221 commented on Jan 8, 2025

    @amk221
    Author

    After having ran ember-cli-update from 5.9.0 to 6.1.0 this is occurring a lot more in our app now

    Uncaught (in promise) Error: Attempted to set the same type of manager multiple times on a value. You can only associate one manager of each type with a given value. Value was (unknown function)
    

    As already mentioned, it may be an addon author applying a modifier, and then, a consumer of the addon applying one of the same type again. Which should be allowed because they aren't in control of 'the fix'.

    As you have already seen my minimal re-production repo, here is a more realistic scenario.

  14. amk221 commented on Jul 24, 2025

    @amk221
    Author

    Fixed by avoiding name clash

    import { modifier as _modifier } from 'ember-modifier';
    const mod1 = _modifier(() => {})
    
    //...
    
    <template><div {{modifier mod2 ...}}></div></template>
  15. 1 remaining item

  16. NullVoxPopuli commented on Sep 10, 2025

    @NullVoxPopuli
    SponsorContributor

    In the REPL -- how do I see the issue?

  17. amk221 commented on Sep 10, 2025

    @amk221
    Author

    Run the tests

    Image
  18. NullVoxPopuli commented on Sep 10, 2025

    @NullVoxPopuli
    SponsorContributor

    REPL with clicks

    gonna try your 6.3 app now (the REPL is using 6.8)

  19. NullVoxPopuli commented on Sep 10, 2025

    @NullVoxPopuli
    SponsorContributor

    I think this has something to do with the route template and controller combo. if I just use components, the problem goes away.

  20. amk221 commented on Sep 10, 2025

    @amk221
    Author

    I ran ember-cli-update (commit), but the error is still there

  21. NullVoxPopuli commented on Sep 10, 2025

    @NullVoxPopuli
    SponsorContributor

    If you're wanting to be unblocked -- can you try moving to components instead of controller + template? does that fix your issue?

  22. amk221 commented on Sep 10, 2025

    @amk221
    Author

    Thanks its a good idea, but I tried it: First by removing use of controllers, and Secondly by switching to ember-route-templates to make doubly sure.

  23. amk221 commented on Sep 10, 2025

    @amk221
    Author

    Well its not a true representation of the minimal reproduction of the issue, its not using arguments

  24. NullVoxPopuli commented on Sep 10, 2025

    @NullVoxPopuli
    SponsorContributor
  25. amk221 commented on Sep 10, 2025

    @amk221
    Author
    Image
  26. NullVoxPopuli commented on Sep 10, 2025

    @NullVoxPopuli
    SponsorContributor

    yup -- and with the debug tools open, it can be debugged the same as your repro repo 🎉

    though, the error is slightly different. I was never able to see .for in the error

  27. amk221 commented on Sep 10, 2025

    @amk221
    Author

    (Thats why I made the github repo, to be as close to the real problem in our app as possible!)

  28. amk221 commented on Sep 10, 2025

    @amk221
    Author

    Please can the issue be reopened?

  29. NullVoxPopuli commented on Sep 10, 2025

    @NullVoxPopuli
    SponsorContributor

    Based on the discussion and prior triage at the top of this issue, i'd prefer a new issue so we start with a clean slate -- in this issue, there are like 5 different problems being looked at

    e.g.:
    Image

    good news though -- you already have a good reproduction, and that's a great place to start. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions