Skip to content
New issue

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

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

Already on GitHub? # to your account

Cannot read properties of undefined (in rrweb) #15948

Closed
3 tasks done
jlowcs opened this issue Apr 1, 2025 · 2 comments · Fixed by getsentry/rrweb#244
Closed
3 tasks done

Cannot read properties of undefined (in rrweb) #15948

jlowcs opened this issue Apr 1, 2025 · 2 comments · Fixed by getsentry/rrweb#244
Assignees
Labels
Package: react Issues related to the Sentry React SDK Package: replay Issues related to the Sentry Replay SDK

Comments

@jlowcs
Copy link

jlowcs commented Apr 1, 2025

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

9.10.1

Framework Version

React 18.3.1

Link to Sentry event

N/A

Reproduction Example/SDK Setup

No response

Steps to Reproduce

Hard to reproduce, but it seems to be related to a third-party utility that makes changes to the DOM.

It results in an error in the browser console pointing to a genAdds function, which I'm pretty sure is this line.

Image

I think adding a check that n.childNodes is defined should do the trick:

      if (n.childNodes)
        n.childNodes.forEach((childN) => this.genAdds(childN));

Expected Result

No error in the console

Actual Result

error in the console

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 1, 2025
@github-actions github-actions bot added the Package: react Issues related to the Sentry React SDK label Apr 1, 2025
@andreiborza andreiborza added the Package: replay Issues related to the Sentry Replay SDK label Apr 2, 2025
@andreiborza
Copy link
Member

Hi, thanks for investigating and filing this! Would you like to contribute this and open up a PR? No pressure, we can also take care of that.

@mydea mydea self-assigned this Apr 2, 2025
@mydea
Copy link
Member

mydea commented Apr 2, 2025

Hmm, technically speaking we should do el. hasChildNodes() before accessing the child nodes, apparently (see https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes#simple_usage).

I'll see if we can fix this easily...

mydea added a commit to getsentry/rrweb that referenced this issue Apr 2, 2025
See https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes#simple_usage

This is typed weirdly, because apparently you should check for existence here. Technically doing `node.hasChildNodes()` would be correct, but since we tend to serialize stuff here or there I feel this is safer (and we already do that in other places too).

Closes getsentry/sentry-javascript#15948
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Package: react Issues related to the Sentry React SDK Package: replay Issues related to the Sentry Replay SDK
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants