Skip to content

[BUGFIX lts] Release renderComponent roots (and renderers) when the result is destroyed - #21647

Merged
ef4 merged 1 commit into
emberjs:mainfrom
NullVoxPopuli-ai-agent:fix/render-component-root-leak
Oct 6, 2026
Merged

ef4 merged 1 commit into
emberjs:mainfrom
NullVoxPopuli-ai-agent:fix/render-component-root-leak

Conversation

@NullVoxPopuli

@NullVoxPopuli NullVoxPopuli commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

I tried out claude-cloud for this.
Description from claude:

RenderResult#destroy() only destroyed the inner Glimmer render result, never the ComponentRootState that wraps it. The root stayed in the renderer's roots list, so the renderer was never deregistered from the global renderers list, which kept the root, its args and its into element alive forever.

This is most visible when renderComponent is called without an owner (e.g. from a modifier): each call creates a new renderer, so every render/destroy cycle leaked a whole renderer and the detached element.

Now destroying the result (or the owner) destroys the root, and a destroyed root removes itself from its renderer, deregistering the renderer once it has no roots left.

Claude-Session: https://claude.ai/code/session_01U6oM2SghwZ7bgTerTEx2hd

…royed

`RenderResult#destroy()` only destroyed the inner Glimmer render result,
never the `ComponentRootState` that wraps it. The root stayed in the
renderer's `roots` list, so the renderer was never deregistered from the
global `renderers` list, which kept the root, its args and its `into`
element alive forever.

This is most visible when `renderComponent` is called without an owner
(e.g. from a modifier): each call creates a new renderer, so every
render/destroy cycle leaked a whole renderer and the detached element.

Now destroying the result (or the owner) destroys the root, and a
destroyed root removes itself from its renderer, deregistering the
renderer once it has no roots left.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01U6oM2SghwZ7bgTerTEx2hd
@NullVoxPopuli
NullVoxPopuli marked this pull request as ready for review October 1, 2026 20:16
@NullVoxPopuli-ai-agent

Copy link
Copy Markdown
Contributor

Without the fix, the two new tests fail. With the fix, all renderComponent tests pass.

Run Pass Fail Skip
PR head bbac5be 47 0 2
Same tests, base-renderer.ts from main (f693f24) 45 2 2

The two failures without the fix:

not ok 26 Chrome 152.0 - Strict Mode - renderComponent:  destroying the result releases its root and renderer
    actual: 24
    expected: 19
    message: renderers for destroyed renderComponent results are not retained

not ok 27 Chrome 152.0 - Strict Mode - renderComponent:  destroying the result removes its root from a shared renderer
    actual: 6
    expected: 1
    message: destroyed roots are not retained

Each of the five render and destroy cycles leaked one renderer in the first test.
The five destroyed roots stayed in the shared renderer in the second test.
The other 45 tests pass in both runs.

To reproduce:

git checkout f693f240ee -- packages/@ember/-internals/glimmer/lib/base-renderer.ts
pnpm vite build --mode development --minify false
pnpm testem ci -f <testem config>

The testem config is a copy of testem.cjs with test_page: 'index.html/?filter=renderComponent' and the tap reporter.

@ef4
ef4 merged commit 847411c into emberjs:main Oct 6, 2026
70 checks passed
This was referenced Oct 6, 2026
kategengler pushed a commit that referenced this pull request Oct 13, 2026
…esult is destroyed

`RenderResult#destroy()` only destroyed the inner Glimmer render result,
never the `ComponentRootState` that wraps it. The root stayed in the
renderer's `roots` list, so the renderer was never deregistered from the
global `renderers` list, which kept the root, its args and its `into`
element alive forever.

This is most visible when `renderComponent` is called without an owner
(e.g. from a modifier): each call creates a new renderer, so every
render/destroy cycle leaked a whole renderer and the detached element.

Now destroying the result (or the owner) destroys the root, and a
destroyed root removes itself from its renderer, deregistering the
renderer once it has no roots left.

Backport of #21647 (bbac5be). On
`lts-6-12` the renderer is in `renderer.ts`, and the render cache held
only the `RenderResult`. The cache entry now also holds the Glimmer
result, so a repeated render into the same target only destroys a
result that rendered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kategengler pushed a commit that referenced this pull request Oct 13, 2026
…he result is destroyed

`RenderResult#destroy()` only destroyed the inner Glimmer render result,
never the `ComponentRootState` that wraps it. The root stayed in the
renderer's `roots` list, so the renderer was never deregistered from the
global `renderers` list, which kept the root, its args and its `into`
element alive forever.

This is most visible when `renderComponent` is called without an owner
(e.g. from a modifier): each call creates a new renderer, so every
render/destroy cycle leaked a whole renderer and the detached element.

Now destroying the result (or the owner) destroys the root, and a
destroyed root removes itself from its renderer, deregistering the
renderer once it has no roots left.

Backport of #21647. The `release` branch does not have the `Cursor`
render cache key, so `renderComponent` keeps `into` as the key.

(cherry picked from commit bbac5be)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
NullVoxPopuli pushed a commit that referenced this pull request Oct 13, 2026
…esult is destroyed

`RenderResult#destroy()` only destroyed the inner Glimmer render result,
never the `ComponentRootState` that wraps it. The root stayed in the
renderer's `roots` list, so the renderer was never deregistered from the
global `renderers` list, which kept the root, its args and its `into`
element alive forever.

Now destroying the result (or the owner) destroys the root, and a
destroyed root removes itself from its renderer, deregistering the
renderer once it has no roots left.

(cherry picked from commit 847411c, #21647)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
betocantu93 added a commit to prysmex/ember-eui that referenced this pull request Oct 14, 2026
7.3.1 releases renderComponent roots and renderers when their owner is
destroyed (emberjs/ember.js#21647), which fixes the per-test memory
retention found by the leak audit.

It was published today, inside pnpm's minimum release age, so
pnpm-workspace.yaml excludes exactly [email protected] from that check.
Remove the exclusion once the release is old enough.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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

Successfully merging this pull request may close these issues.

4 participants