You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Infinite revalidation bug error thrown in willDestroyElement calls if we set any parent properties inside it in Ember versions higher than 5.5.0 #20707
We recently upgraded our ember application from version 3.28 to v5.9.0. After upgrade some cleanup operations using willDestroyElement calls in ember component throws infinite revalidation bug error, but when we use willDestroy method or registerDestructor function, this issue doesn't occur.
changed the title [-]`Infinite revalidation` bug error thrown in willDestroyElement calls in Ember versions higher than 5.5.0 [/-][+]`Infinite revalidation` bug error thrown in willDestroyElement calls if we set any parent properties inside it in Ember versions higher than 5.5.0 [/+]on Jun 19, 2024
Discussed in discord, an alternative is to switch to willDestroy, from willlDestroyElement, which will also help in migration to Glimmer components (since glimmer components don't have willDestroyElement)
Do we expicitly set the element of a classic component to null | undefined after willDestroyElement or will it be garbage collected when component instance is cleared?
Yeah. I'm asking can we able to access the HTML element in the willDestroy hook or will be set as null | undefined by the framework after the willDestroyElement hook call
Activity
[-]`Infinite revalidation` bug error thrown in willDestroyElement calls in Ember versions higher than 5.5.0 [/-][+]`Infinite revalidation` bug error thrown in willDestroyElement calls if we set any parent properties inside it in Ember versions higher than 5.5.0 [/+]NullVoxPopuli commentedon Jun 19, 2024
Thanks for the reproduction!
after looking through your code, it seems like you don't want destruction to auto-track.
A work-around (we'll need to defer to @chancancode to know if this is a bug or not),
is to change:
https://github.com/tamil-arasu849/ember-lifecycle-hook-bug-repo/blob/main/app/components/example.js#L10
to
tamil-arasu849 commentedon Jun 19, 2024
But this change breaks many of our existing components, so had to downgrade to v5.5.0. Also we can't do this handling in all places right!

NullVoxPopuli commentedon Jun 19, 2024
Discussed in discord, an alternative is to switch to
willDestroy, fromwilllDestroyElement, which will also help in migration to Glimmer components (since glimmer components don't havewillDestroyElement)tamil-arasu849 commentedon Jun 19, 2024
Won't it cause any issue if we use
willDestroyin classic components? @NullVoxPopuli @chancancodeNullVoxPopuli commentedon Jun 19, 2024
why would it? -- it exists in classic components
https://api.emberjs.com/ember/5.9/classes/Component/methods/willDestroy?anchor=willDestroy
kategengler commentedon Jun 24, 2024
I believe switching to
willDestroywould only be an issue where you need access to the element inwillDestroyElement.tamil-arasu849 commentedon Jun 27, 2024
Do we expicitly set the
elementof a classic component to null | undefined afterwillDestroyElementor will it be garbage collected when component instance is cleared?NullVoxPopuli commentedon Jun 27, 2024
it'll be cleaned up, all handled by the framework <3
tamil-arasu849 commentedon Jun 27, 2024
Yeah. I'm asking can we able to access the
HTML elementin thewillDestroyhook or will be set as null | undefined by the framework after thewillDestroyElementhook callNullVoxPopuli commentedon Jun 27, 2024
I don't recall, that'd be a good thing to try -- what is
this.elementkategengler commentedon Jun 27, 2024
I don't believe the element is available in
willDestroy-- otherwise we would not have neededwillDestroyElementas a hook.NullVoxPopuli commentedon Nov 12, 2024
Thank you for the reproduction, I've put it all in a gjs file over here: https://github.com/NullVoxPopuli/repro-destruction-tracking
NullVoxPopuli commentedon Nov 12, 2024
What's interesting is that if I remove the middle component, both 5.5 and 5.6+ error
So something about that middle
Examplecomponent is protecting 5.5 (or broke in 5.6+)NullVoxPopuli commentedon Nov 22, 2024
Good news -- switching to
@glimmer/component, and usingregisterDestructorvia:is a good way to migrate away from this problem.
tamil-arasu849 commentedon Nov 25, 2024
Yeah. We used
registerDestructorin places where we faced the computation issue and its working fine for uskategengler commentedon Nov 25, 2024
@NullVoxPopuli Does
registerDestructorwork with@ember/component?NullVoxPopuli commentedon Nov 25, 2024
It does, ya. And is async, so it would avoid the problem altogether
(Sync destruction is the problem here, so i don't think we have a bug)
kategengler commentedon Nov 25, 2024
It is a bug in that code that worked in 5.4 doesn't work in >= 5.5
NullVoxPopuli commentedon Nov 25, 2024
I think the bug is that it ever worked at all