This repository was archived by the owner on Jan 30, 2026. It is now read-only.
Closed
Conversation
Co-authored-by: caiopizzol <caiopizzol@gmail.com>
|
Cursor Agent can help with this pull request. Just |
SD-543 Fix memory leak: clear trigger refs on unmount
SummaryEnsure cleanup refs are cleared on unmount to prevent memory leaks when component is destroyed during active menu interaction Tasks
NotesProblem: When component unmounts while menu is open or trigger is active, refs hold closures that reference editor/DOM that no longer exist Current code (src/index.tsx ~line 400): return () => {
if (superdocRef.current) {
if (typeof superdocRef.current.destroy === 'function') {
superdocRef.current.destroy();
}
superdocRef.current = null;
}
};Missing: Clear Fix: return () => {
// Clear trigger refs
triggerCleanupRef.current = null;
menuTriggerFromRef.current = null;
// Destroy editor
if (superdocRef.current) {
if (typeof superdocRef.current.destroy === 'function') {
superdocRef.current.destroy();
}
superdocRef.current = null;
}
};Verification: Mount component → type trigger → unmount → verify no memory leaks in Chrome DevTools |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Clear trigger-related refs and SuperDoc instance on unmount to prevent memory leaks.
When the component unmounts, especially during active menu interaction, lingering references in
triggerCleanupRefandmenuTriggerFromRefcan hold closures that reference unmounted DOM elements or editor instances, leading to memory leaks. This change ensures these references are explicitly nulled out.Linear Issue: SD-543