-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix: more robust rootShadowHost
check
#50
Conversation
@@ -282,7 +282,7 @@ export default class MutationBuffer { | |||
// ensure shadowHost is a Node, or doc.contains will throw an error | |||
const notInDoc = | |||
!this.doc.contains(n) && | |||
(rootShadowHost === null || !this.doc.contains(rootShadowHost)); | |||
(!rootShadowHost || !this.doc.contains(rootShadowHost)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm would you mind explaining how this fixes the reported issue?
Not sure what I'm missing here but I tried reproducing this locally, by explicitly calling this.doc.contains(undefined)
but the call seemed to return false
and didn't crash.
Also, any chance that this is caused by the line above (n
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ofc chances are that in my simple test app, doc
is handling the contains call somewhat differently than in Sentry...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, oof, I thought that contains(undefined)
would break it. If that works, then this isn't a fix at all, then it obv. is a different issue. Then I guess we'd need to do a rootShadowHost instanceof Node
check or something along these lines 🤔
Note this was reported upstream as well: rrweb-io#1114 |
https://github.com/rrweb-io/rrweb/pull/891/files This is a similar fix. |
Ah, interesting, so I guess we can merge this after all! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then let's go 🚀
Should fix getsentry/sentry-javascript#7274 |
This may be the underlying cause here, maybe an e.g.
undefined
sneaked in there somehow. IMHO this should also safe some bytes.