Skip to content

fix: avoid disposal-order crash in Angular renderer teardown (#1220)#1234

Merged
mathuo merged 1 commit intomasterfrom
fix/angular-renderer-disposal-1220
May 5, 2026
Merged

fix: avoid disposal-order crash in Angular renderer teardown (#1220)#1234
mathuo merged 1 commit intomasterfrom
fix/angular-renderer-disposal-1220

Conversation

@mathuo
Copy link
Copy Markdown
Owner

@mathuo mathuo commented May 4, 2026

Summary

  • Fixes Error: Angular renderer not initialized on destroy #1220Error: Angular renderer not initialized thrown from OverlayRenderContainer during dockview destroy.
  • Disposal-order bug: OverlayRenderContainer's per-panel destroy disposable reads panel.view.content.element to detach the node from its overlay parent. The Angular renderer's dispose() was nulling _element before that destroy disposable ran, so the getter threw mid-cascade and aborted the rest of the teardown.

Fixes

Two complementary changes:

  1. AngularRenderer.dispose() no longer nulls _element.
    The underlying HTMLElement is a cheap reference to retain and the JS object is still valid after Angular has destroyed the component/view. Keeping it around lets external cleanup paths (dockview-core's overlay teardown) still see and detach the node from its overlay parent. The element will be GC'd when the renderer itself is collected.

  2. OverlayRenderContainer.attach() captures the content element at attach time.
    The destroy disposable now uses that captured local instead of re-querying panel.view.content.element. This hardens the container against any framework adapter that nulls its element on dispose, not just the Angular case.

Files changed

  • packages/dockview-angular/src/lib/utils/angular-renderer.ts — drop this._element = null in dispose().
  • packages/dockview-core/src/overlay/overlayRenderContainer.ts — capture contentElement once in attach() and reuse in the destroy disposable.
  • packages/dockview-angular/src/__tests__/angular-renderer.spec.ts — flipped the existing post-dispose test, added regression test for Error: Angular renderer not initialized on destroy #1220 and a guard test that the getter still throws when accessed before init().
  • packages/dockview-core/src/__tests__/overlay/overlayRenderContainer.spec.ts — added two regression tests simulating a renderer whose element getter throws after disposal (covers both detatch() and full container dispose() paths).

Test plan

  • yarn jest in packages/dockview-core — 847/847 (was 845, +2 new).
  • yarn jest in packages/dockview-angular — 122/122 (was 120, +2 new, 1 existing test flipped to match new contract).
  • yarn build:cjs in packages/dockview-core — no type errors.
  • Manual repro in an Angular 21 host: mount dockview, then destroy the parent component — should no longer log Angular renderer not initialized.

🤖 Generated with Claude Code

When dockview is destroyed, OverlayRenderContainer's per-panel destroy
disposable reads `panel.view.content.element` to detach the node from
its overlay parent. The Angular renderer was nulling its own element
reference inside dispose(), so that getter threw "Angular renderer not
initialized" mid-cascade and aborted the rest of the teardown.

Two complementary fixes:

- AngularRenderer.dispose no longer nulls _element. The HTMLElement is
  cheap to retain and lets external cleanup paths still detach the node
  from its parent after the Angular component has been destroyed.
- OverlayRenderContainer.attach now captures the content element at
  attach time and uses that local reference in its destroy disposable
  instead of re-querying through the renderer. This hardens the
  container against any framework adapter that nulls its element on
  dispose.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

@mathuo mathuo merged commit 94ee918 into master May 5, 2026
9 checks passed
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.

Error: Angular renderer not initialized on destroy

1 participant