Repository navigation
Description
🐞 Describe the Bug
On ember-source 7.3.0 (development build), a render that throws can leave a global tracking frame open for the rest of the test run.
VM.execute's DEBUG error path cleans up in this order:
- it closes the open blocks (
popBlock()); - then it calls
resetTracking().
When popBlock() throws (its DOM is already gone), that exception escapes the finally, and resetTracking() never runs. CURRENT_TRACKER and the - While rendering: {ROOT} tracking transaction stay open. From then on, every tracked write fails as a backtracking assertion, in every later test, including unit tests that render nothing.
We hit it through @ember/test-helpers 5.7. Since ember-test-helpers#1580, render() and clearRender() go through renderComponent for ember-source >= 6.12.1. The sequence is:
- A test's
render()fails while installing a modifier (inTransactionImpl.commit).renderComponentexits beforeRENDER_CACHE.set(into, …). - The test's
clearRender()renders into the same element. Nothing is cached for it, sorenderComponentsetsinto.innerHTML = ''under the failed root, which is still registered. - The new render then fails in the VM. Unwinding its blocks throws
NotFoundError: Failed to execute 'insertBefore' on 'Node', so tracking is never reset.
In our app's suite, one such test turned ~1,000 later tests red.
🔬 Minimal Reproduction
Two tests in one module, run in order in a Vite + Embroider app on ember-source 7.3.0 with @ember/test-helpers 5.7.0:
import { on } from '@ember/modifier';
import { tracked } from '@glimmer/tracking';
import { clearRender, render, resetOnerror, settled, setupOnerror } from '@ember/test-helpers';
import { setupRenderingTest } from 'ember-qunit';
import { module, test } from 'qunit';
class State {
@tracked value = 0;
}
module('a render that throws', function (hooks) {
setupRenderingTest(hooks);
hooks.afterEach(() => resetOnerror());
test('throws', async function (assert) {
const errors = [];
setupOnerror((e) => errors.push(e.message));
try {
await render(<template><button {{on "click" undefined}}>x</button></template>);
} catch (e) {
errors.push(e.message);
}
assert.true(errors[0]?.includes('to the `on` modifier'));
try {
await clearRender();
} catch {}
});
test('the next test', async function (assert) {
const state = new State();
await render(<template>{{state.value}}</template>);
state.value = 1;
await settled();
assert.dom().hasText('1');
});
});The test build must resolve Ember's development build (the development export condition). With vite build --mode development, Vite resolves production unless NODE_ENV=development, and the production build has no DEBUG path at all.
Right after the clearRender(), isTracking() from @glimmer/validator returns true, and debug.resetTrackingTransaction() returns "- While rendering:\n {ROOT}…".
😕 Actual Behavior
the next test fails, as does every test after it. In our app, the first tracked write in a test is ember-intl's (from an instance-initializer), so the next tests fail at boot:
Promise rejected before "the next test": Assertion Failed: You attempted to update `_intls` on `<IntlService:ember3>`,
but it had already been used previously in the same computation. ...
`_intls` was first used:
- While rendering:
{ROOT}
Without that initializer, I'd expect the same assertion on the test's own state.value = 1. I only ran it in our app.
🤔 Expected Behavior
A render error stays in its own test. The VM's error cleanup always resets tracking, even when closing the open blocks throws, and the next test renders and updates normally.
🌍 Environment
- Ember: ember-source 7.3.0 (
dist/dev), @ember/test-helpers 5.7.0, ember-qunit 9.2.0 - Ember-CLI: 7.3.0, building with Vite 8.3.2 / @embroider/vite 1.7.15 / @embroider/compat 4.1.27
- Node.js/npm: Node 22.22.1, pnpm 12.9.1
- OS: Linux (Docker sandbox)
- Browser: Chrome 155 (headless, testem)
➕ Additional Context
Local fix (a pnpm patch on 7.3.0): wrap the popBlock loop in VM.execute's DEBUG finally in its own try/finally, so resetTracking() always runs:
} finally {
if (hasErrored) {
try {
let elements = this.tree();
while (elements.hasBlocks) elements.popBlock();
} finally {
console.error(`\n\nError occurred:\n\n${resetTracking()}\n\n`);
}
}
}A second, related leak (separate from the cascade): renderComponent creates one renderer per owner (RENDER_CACHE/RENDERER_CACHE), but that renderer is never a destroyable child of the owner. If the first render throws, associateDestroyableChild(owner, …) is never reached. The renderer then stays in the global renderers list, and its root re-renders on every later run loop: the dev build logs "Attempted to rerender, but the Ember application has had an unrecoverable error occur during render…", and the prod build constructs the failed component again. We also patch this with associateDestroyableChild(owner, renderer) where the renderer is created. On its own, that change does not fix the reproduction above.
Results on the reproduction:
| ember-source | the next test |
|---|---|
| stock 7.3.0 | fails, as does every later test |
| renderer change only | fails |
renderer change + resetTracking change |
passes |
(I did not run the resetTracking change on its own.)
Related, but none of these covers this case:
- [BUGFIX lts] Release renderComponent roots (and renderers) when the result is destroyed #21647 (merged 2026-10-06): releases roots and renderers when a
renderComponentresult is destroyed. A render that throws produces no result, andassociateDestroyableChild(owner, root)still runs afterrenderer.render(). - [BUGFIX release] Reset tracking state after a render error in prod #21634 (open): always resets tracking after a render error in production builds. Here the DEBUG path does call
resetTracking(), but a throwingpopBlock()skips it. - Change version check to >=6.12.1 for renderComponent ember-test-helpers#1580:
render()usesrenderComponentfor ember-source >= 6.12.1, which is why this appeared when we upgraded from 6.12.0. - Migrate five more glimmer integration tests to plain .gjs tests with setupRenderingTest #21672 (merged 2026-10-09) moves Ember's own Glimmer integration tests to
setupRenderingTest. The reproduction above would fit that style as a regression test.
Open questions:
- Is
try/finallyaroundpopBlockthe right fix? - Should
renderComponentalso avoid clearinginnerHTML/ rendering under a root whose previous render failed? - Should the renderer
renderComponentcreates be a destroyable child of the owner?
Activity
[-]Bug report[/-][+]a render that throws can leave a global tracking frame open for the rest of the test run.[/+]NullVoxPopuli commentedon Oct 9, 2026
have you tried with ember-source @
main?betocantu93 commentedon Oct 9, 2026
Thanks! I built
main(eef7970b07) and ran our suite against it:The cascade I reported doesn't happen on main. My two-test repro passes, and our full suite (~1,370 tests) has no backtracking cascade: 0
_intlsfailures, versus ~1,000 on 7.3.0. "Attempted to rerender…" warnings also drop from ~4,650 to 35. My guess is that [BUGFIX lts] Release renderComponent roots (and renderers) when the result is destroyed #21647 is what fixes it, though I haven't isolated it. Could that be backported to 7.3 / LTS?The underlying hole is still on main, though. In
VM.execute's DEBUGfinally(packages/@glimmer/runtime/lib/vm/append.ts), ifpopBlock()throws while closing a block whose DOM is gone,resetTracking()is skipped. The tracking frame then stays open for every later render and update. Here is a minimal repro with no test-helpers involved. It fails on 7.3.0 and on main, and passes with atry/finallyaround thepopBlockloop:resetTracking()didn't runeef7970b07The change we're running as a pnpm patch:
betocantu93 commentedon Oct 9, 2026
This of course my friend is AI suggestions and findings while fixing our test suite when moving to ember 7.3
NullVoxPopuli commentedon Oct 9, 2026
are you experiencing this because tests are running in production mode?
(sorry, AI makes too many words, and I get overwhelmed and quit)
betocantu93 commentedon Oct 10, 2026
No, it's the development build. Our test build had been resolving Ember's prod build at first; after fixing that, the repro still fails on 7.3.0 and on main (dev builds). The bug is in VM.execute's DEBUG-only finally: if popBlock() throws, resetTracking() is skipped.
[BUGFIX release] Reset tracking when the cleanup of a render error th…
NullVoxPopuli commentedon Oct 10, 2026
@betocantu93
I noticed:
what do you have that's doing that?
generally this isn't a supported way of manipulating the DOM, and manual DOM manipulation with any SPA has a number of rough edges and is only supported in narrow use cases.
betocantu93 commentedon Oct 10, 2026
Nothing in our app manipulates the DOM. The marker is only to force the failure in a small repro. In our suite the sequence was: a modifier threw during install ({{on "click" undefined}}), then test-helpers' clearRender() rendered into the same element, and that render failed with NotFoundError: insertBefore from popBlock() in VM.execute's cleanup. I didn't pin down which node was missing, but it seems to be the earlier failed render's DOM. Either way, the issue is that an exception while closing blocks skips resetTracking(), which leaves tracking broken for everything after it.
[BUGFIX release] Reset tracking when the cleanup of a render error th…
[BUGFIX release] Reset tracking when the cleanup of a render error th…
NullVoxPopuli commentedon Oct 10, 2026
in #21685, I've left enough context about this that future readers will know what's going on (hopefully).
as this is a dev-time only fix, I'm pretty comfortable with the solution, and am OK with the test being a little goofy
[BUGFIX release] Reset tracking when the cleanup of a render error th…
[BUGFIX release] Reset tracking when the cleanup of a render error th…
[BUGFIX release] Reset tracking when the cleanup of a render error th…
[BUGFIX release] Reset tracking when the cleanup of a render error th…
[BUGFIX release] Reset tracking when the cleanup of a render error th…