Repository navigation
[BUGFIX lts] Destroy dynamic modifiers that were set after the initial render - #21591
Merged
NullVoxPopuli merged 2 commits intoSep 4, 2026
Conversation
A dynamic modifier whose value changes from undefined to a modifier after the first render never runs its destructor when its block is removed or when the render result is destroyed. UpdateDynamicModifierOpcode attaches the new instance's destroyable to itself with associateDestroyableChild(this, destroyable), but the opcode is never registered as a destroyable child of its block. Only block opcodes go through didEnter, which calls associateDestroyable. vm.updateWith only pushes to the updating list. Reported through universal-ember/ember-primitives#805, where the Popover content element leaks @floating-ui/dom observers. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01Fvnp457DHuZC4fBa2KCiqB
…al render Register the UpdateDynamicModifierOpcode as a destroyable child of its block. Instances that the opcode creates on update are attached to the opcode with associateDestroyableChild, so the block now reaches them when it is destroyed. Fixes the leak reported in universal-ember/ember-primitives#805. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01Fvnp457DHuZC4fBa2KCiqB
Contributor
Author
|
CI on the test-only commit (14f95ce) failed on exactly the three new tests and nothing else: https://github.com/emberjs/ember.js/actions/runs/33908583452. The fix is now pushed as the second commit (d8a8382). It needs one more workflow approval. |
kategengler
reviewed
Sep 4, 2026
| (owner) => { | ||
| return new this.CustomModifierManager(owner); | ||
| }, | ||
| class extends EmberObject { |
Member
There was a problem hiding this comment.
Should we be making new tests using EmberObject?
Contributor
Member
|
One comment but otherwise 👍 |
kategengler
approved these changes
Sep 4, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Dynamic modifiers that become defined after the first render never run their destructor. This leaks whatever the modifier set up, for example the
@floating-ui/domobservers behind universal-ember/ember-primitives#805.Mechanism, in
packages/@glimmer/runtime/lib/compiled/opcodes/dom.ts:{{this.mod}}renders withthis.modasundefined. No instance is created, and anUpdateDynamicModifierOpcodeis pushed withvm.updateWith.this.modbecomes a modifier.UpdateDynamicModifierOpcode.evaluatecreates the instance and callsassociateDestroyableChild(this, destroyable).vm.updateWithonly pushes to the updating list, and only block opcodes go throughdidEnter, which callsassociateDestroyable.The same leak happens whenever the dynamic modifier value changes to a different modifier. The replacement instance is attached to the orphaned opcode.
This dates from
cb11136(February 2021), so every Ember release since 3.25 is affected.Earlier reports of the same bug:
clearRender(), is the second new test in this pull request)This pull request is in two commits, so CI can show the failure first:
🤖 Generated with Claude Code
https://claude.ai/code/session_01Fvnp457DHuZC4fBa2KCiqB