Skip to content

fix(bubble): properly clean up viewport meta tag on unmount#393

Open
SyncWithRaj wants to merge 3 commits into
FlowiseAI:mainfrom
SyncWithRaj:fix/bubble-meta-tag-cleanup
Open

fix(bubble): properly clean up viewport meta tag on unmount#393
SyncWithRaj wants to merge 3 commits into
FlowiseAI:mainfrom
SyncWithRaj:fix/bubble-meta-tag-cleanup

Conversation

@SyncWithRaj

@SyncWithRaj SyncWithRaj commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Describe the Bug

In src/features/bubble/components/Bubble.tsx, the code used createEffect to dynamically inject a viewport <meta> tag into the host document's <head>. It attempted to clean up the tag by returning a function from the effect.
While returning a function works for cleanup in React (useEffect), Solid.js ignores the return value of createEffect. As a result, the cleanup function was never executed.

Impact

Every time the chat widget was mounted, a new tag was permanently injected into the host website's DOM. If the widget was unmounted and remounted, it polluted the host with duplicate meta tags, which could interfere with the host site's own responsive design rules.

Solution

  • Replaced createEffect with onMount.
  • Used Solid.js's native onCleanup hook to correctly handle the removal of the DOM element upon unmount.
  • Removed the unused createEffect import.

fixes #380

Replaced createEffect with onMount and used Solid.js's native onCleanup to ensure the dynamically injected viewport <meta> tag is properly removed from the DOM when the widget is unmounted. Solid.js ignores returned functions in createEffect, which previously caused a new meta tag to be permanently left in the document head every time the chat widget mounted.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the dynamic viewport meta tag insertion in the Bubble component by replacing createEffect with onMount and nested onCleanup. The review feedback suggests a safer approach to removing the meta tag by using meta.remove() instead of document.head.removeChild(meta) to prevent potential DOM exceptions.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.


return () => {
onCleanup(() => {
document.head.removeChild(meta);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using document.head.removeChild(meta) can throw a NotFoundError DOMException if the meta tag has already been removed or detached from the document head by another script or parent container cleanup. Using meta.remove() is a safer, more defensive alternative that gracefully handles cases where the element is no longer in the DOM.

Suggested change
document.head.removeChild(meta);
meta.remove();

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.

bug: Viewport meta tag is never removed (Solid.js cleanup memory leak)

1 participant