From 1372438f8e87de0adcd275a19c78661fd9dc600b Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Wed, 5 Nov 2025 10:22:17 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(frontend)=20fix=20memory=20leak=20?= =?UTF-8?q?in=20Interlinking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When doing collaborative editing, doc?.title might be out of sync for other users when updated by another user. This causes the useEffect to run repeatedly, causing an infinite loop of updates. We now trigger the effect only when doc?.title changes, not when the customInlineContent changes. --- CHANGELOG.md | 1 + .../Interlinking/InterlinkingLinkInlineContent.tsx | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3c1913e..efc2c732 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to - ♿(frontend) remove empty alt on logo due to Axe a11y error #1516 - 🐛(backend) fix s3 version_id validation - 🐛(frontend) retry check media status after page reload #1555 +- 🐛(frontend) fix Interlinking memory leak #1560 ## [3.8.2] - 2025-10-17 diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-inline-content/Interlinking/InterlinkingLinkInlineContent.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-inline-content/Interlinking/InterlinkingLinkInlineContent.tsx index 8f5d30a3..769d6c15 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-inline-content/Interlinking/InterlinkingLinkInlineContent.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-inline-content/Interlinking/InterlinkingLinkInlineContent.tsx @@ -29,6 +29,9 @@ export const InterlinkingLinkInlineContent = createReactInlineContentSpec( render: ({ inlineContent, updateInlineContent }) => { const { data: doc } = useDoc({ id: inlineContent.props.docId }); + /** + * Update the content title if the referenced doc title changes + */ useEffect(() => { if (doc?.title && doc.title !== inlineContent.props.title) { updateInlineContent({ @@ -39,7 +42,15 @@ export const InterlinkingLinkInlineContent = createReactInlineContentSpec( }, }); } - }, [inlineContent.props, doc?.title, updateInlineContent]); + + /** + * ⚠️ When doing collaborative editing, doc?.title might be out of sync + * causing an infinite loop of updates. + * To prevent this, we only run this effect when doc?.title changes, + * not when inlineContent.props.title changes. + */ + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [doc?.title]); return ; },