fix: avoid disposal-order crash in Angular renderer teardown (#1220)#1234
Merged
fix: avoid disposal-order crash in Angular renderer teardown (#1220)#1234
Conversation
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>
|
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.



Summary
Error: Angular renderer not initializedthrown fromOverlayRenderContainerduring dockview destroy.OverlayRenderContainer's per-paneldestroydisposable readspanel.view.content.elementto detach the node from its overlay parent. The Angular renderer'sdispose()was nulling_elementbefore that destroy disposable ran, so the getter threw mid-cascade and aborted the rest of the teardown.Fixes
Two complementary changes:
AngularRenderer.dispose()no longer nulls_element.The underlying
HTMLElementis 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.OverlayRenderContainer.attach()captures the content element at attach time.The
destroydisposable now uses that captured local instead of re-queryingpanel.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— dropthis._element = nullindispose().packages/dockview-core/src/overlay/overlayRenderContainer.ts— capturecontentElementonce inattach()and reuse in thedestroydisposable.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 beforeinit().packages/dockview-core/src/__tests__/overlay/overlayRenderContainer.spec.ts— added two regression tests simulating a renderer whoseelementgetter throws after disposal (covers bothdetatch()and full containerdispose()paths).Test plan
yarn jestinpackages/dockview-core— 847/847 (was 845, +2 new).yarn jestinpackages/dockview-angular— 122/122 (was 120, +2 new, 1 existing test flipped to match new contract).yarn build:cjsinpackages/dockview-core— no type errors.Angular renderer not initialized.🤖 Generated with Claude Code