Skip to content

fix(feedback): Prevent removeFromDom() from throwing #16030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

ryan953
Copy link
Member

@ryan953 ryan953 commented Apr 10, 2025

An internal user reported seeing "NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node." and the replay of their session confirms it: https://sentry.sentry.io/explore/replays/127444034ae84099a84b524458b6dd90/

However, there is no matching JS error to give more clues.

What I think happened is that after interacting with the Feedback SDK the widget got into a state where it was no longer mounted into the page, but we called removeFromDom() anyway.

Looking at the replay i saw the moment when the feedback dom was aded to the page, but it wasn't visible, only this got added at 18:51:
SCR-20250411-lsav

So something prevented it from opening all the way up.

Fixes getsentry/sentry#89424

@ryan953 ryan953 requested a review from a team as a code owner April 10, 2025 22:10
Copy link

codecov bot commented Apr 10, 2025

❌ We are unable to process any of the uploaded JUnit XML files. Please ensure your files are in the right format.

logger.error(
'[Feedback] Error when trying to remove Actor from the DOM. It is not appended to the DOM yet!',
);
throw new Error('[Feedback] Actor is not appended to DOM, nothing to remove.');
Copy link
Member

Choose a reason for hiding this comment

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

Why do you want to throw this one here?

Copy link
Member Author

Choose a reason for hiding this comment

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

turns out el.remove() doesn't even throw if there's no parent element. unlike parent.removeChild(child).

So now if people call removeFromDom() we'll basically guarantee that the elements will be removed, and there'll be no errors thrown.

Similar to the appendToDom() call, SDK users can't really tell what state things are currently in, but they can call methods to put things into the state you want to be in.

@ryan953 ryan953 marked this pull request as draft April 11, 2025 15:24
@ryan953 ryan953 force-pushed the ryan953/fix-feedback-throws branch from 7a904c7 to 18c9875 Compare April 14, 2025 20:42
@ryan953 ryan953 force-pushed the ryan953/fix-feedback-throws branch from 96483aa to 0463304 Compare April 14, 2025 21:00
@ryan953 ryan953 force-pushed the ryan953/fix-feedback-throws branch from 0463304 to b85449b Compare April 14, 2025 21:02
@ryan953 ryan953 marked this pull request as ready for review April 14, 2025 21:05
@ryan953 ryan953 requested review from a team and chargome April 14, 2025 21:05
Copy link
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.28 KB - -
@sentry/browser - with treeshaking flags 23.12 KB - -
@sentry/browser (incl. Tracing) 36.99 KB - -
@sentry/browser (incl. Tracing, Replay) 74.17 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 67.55 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 78.83 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 90.65 KB -0.01% -8 B 🔽
@sentry/browser (incl. Feedback) 39.67 KB -0.03% -10 B 🔽
@sentry/browser (incl. sendFeedback) 27.9 KB - -
@sentry/browser (incl. FeedbackAsync) 32.67 KB -0.02% -5 B 🔽
@sentry/react 25.09 KB - -
@sentry/react (incl. Tracing) 38.91 KB - -
@sentry/vue 27.51 KB - -
@sentry/vue (incl. Tracing) 38.71 KB - -
@sentry/svelte 23.32 KB - -
CDN Bundle 24.51 KB - -
CDN Bundle (incl. Tracing) 36.98 KB - -
CDN Bundle (incl. Tracing, Replay) 72.03 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 77.17 KB -0.01% -6 B 🔽
CDN Bundle - uncompressed 71.47 KB - -
CDN Bundle (incl. Tracing) - uncompressed 109.34 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 220.63 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 233.15 KB -0.01% -12 B 🔽
@sentry/nextjs (client) 40.53 KB - -
@sentry/sveltekit (client) 37.44 KB - -
@sentry/node 143.23 KB - -
@sentry/node - without tracing 96.47 KB - -
@sentry/aws-serverless 120.77 KB - -

View base workflow run

@ryan953 ryan953 changed the title fix(feedback): Fix an issue where, if removeFromDom() is called it might throw fix(feedback): Prevent removeFromDom() from throwing Apr 15, 2025
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.

User Feedback causes page to crash?
2 participants