[ZEPPELIN-6532] Complete destroy$ in paragraph ngOnDestroy to stop leaking subscriptions#5322
Open
JangAyeon wants to merge 1 commit into
Open
[ZEPPELIN-6532] Complete destroy$ in paragraph ngOnDestroy to stop leaking subscriptions#5322JangAyeon wants to merge 1 commit into
JangAyeon wants to merge 1 commit into
Conversation
…aking subscriptions ngOnDestroy() only called super.ngOnDestroy(), which tears down the @MessageListener subscriptions and nothing else. destroy$ was never emitted or completed, so subscriptions gated on takeUntil(this.destroy$) - keyBinderService.keyEvent(), angularContextManager.runParagraphAction(), and .contextChanged() - kept running against singleton services after a paragraph was destroyed, and the keydown listeners KeyBinder registered through shortcutService.bindShortcut() were never released. Emit and complete destroy$ in ngOnDestroy after super.ngOnDestroy(), matching the pattern already used in result.component.ts and dynamic-forms.component.ts.
tbonelee
approved these changes
Jul 19, 2026
tbonelee
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Clean, minimal fix for the leak.
Verified the reasoning holds:
destroy$is a localSubject(paragraph.component.ts:147) that was never completed, so thetakeUntil(this.destroy$)subscriptions on singleton services (keyEvent(),runParagraphAction(),contextChanged()) kept a destroyed paragraph alive.- The shortcut listeners are released too:
KeyBinderreceivesdestroy$and gatesbindShortcut(...)withtakeUntil(this.destroySubject)(key-binder.ts:53), so completingdestroy$tears them down. - All
.subscribe()sites in the component are gated bytakeUntil(destroy$), so no leak remains after this change.
Keeping super.ngOnDestroy() first is correct, and the destroy$.next(); destroy$.complete(); pattern matches the existing usage in dynamic-forms.component.ts.
Contributor
|
Small request: the Jira link in the PR description points to |
Author
Fixed the Jira link in the PR description — it now points to ZEPPELIN-6532 and resolves correctly. |
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.
What is this PR for?
Destroying a notebook paragraph did not tear down its own long-lived subscriptions or the shortcut key listeners it registered. ngOnDestroy() only called super.ngOnDestroy(), which (via MessageListenersManager) unsubscribes
the @MessageListener subscriptions but never touches destroy$. Subscriptions gated on takeUntil(this.destroy$) - keyBinderService.keyEvent(), angularContextManager.runParagraphAction(), and .contextChanged() - are on singleton services, so a destroyed paragraph instance stayed reachable and kept receiving callbacks after being removed from the DOM. The shortcut keydown listeners registered by KeyBinder via shortcutService.bindShortcut() were also never released.
This PR emits and completes destroy$ in ngOnDestroy, after super.ngOnDestroy(), matching the pattern already used in result.component.ts and dynamic-forms.component.ts.
What type of PR is it?
Bug Fix
Todos
What is the Jira issue?
ZEPPELIN-6532
How should this be tested?
cd zeppelin-web-angular && npm run lintQuestions: