Skip to content

Conversation

@billyvg
Copy link
Member

@billyvg billyvg commented Oct 22, 2025

Not sure yet how this is happening during recording, but prevent player from calling setAttribute on TEXT nodes (which does not have that method). This additionally prevents the player from freezing while trying to process these invalid mutations.

Not sure yet how this is happening during recording, but prevent player from calling `setAttribute` on TEXT nodes (which does not have that method). This additionally prevents the player from freezing while trying to process these invalid mutations.
@billyvg billyvg force-pushed the billy/fix-set-attribute-text-node branch from c8e0fc8 to aba4b9b Compare October 22, 2025 21:49
@billyvg billyvg changed the title fix(rrweb-player): Remove duplicate playback ui (#251) fix(rrweb): Do not call setAttribute on TEXT nodes Oct 22, 2025
@billyvg billyvg requested a review from a team October 22, 2025 21:58
@billyvg billyvg marked this pull request as ready for review October 22, 2025 21:58
@billyvg
Copy link
Member Author

billyvg commented Oct 22, 2025

@sentry review

Comment on lines +1954 to +1961

Choose a reason for hiding this comment

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

The guard condition only checks for Text nodes (nodeType !== 3), but other node types such as COMMENT_NODE (8), PROCESSING_INSTRUCTION_NODE (7), or DOCUMENT_FRAGMENT_NODE (11) also lack the setAttribute method. While the immediate issue may only manifest with Text nodes, consider using a more robust check like instanceof Element or typeof target.setAttribute === 'function' to make the code more defensive against future edge cases and document types that might appear during recording.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we record any of those types, so this should suffice

// prevents calling `setAttribute` on Text nodes (which does not
// have `setAttribute` method).
if (target.nodeType !== 3) {
(target as Element | RRElement).setAttribute(
Copy link
Member

Choose a reason for hiding this comment

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

The Sentry suggestion to check typeof target.setAttribute === 'function' seems reasonable instead of going with nodeType=3 no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I want it to be more specific since this shouldn't happen at all. Something seems to be wrong during recording where we are getting the wrong mutations (or the wrong element references for the mutation), so ideally this is just temporary assuming we can repro and fix the recording side.

@billyvg billyvg merged commit 672f514 into sentry-v2 Oct 23, 2025
17 checks passed
@billyvg billyvg deleted the billy/fix-set-attribute-text-node branch October 23, 2025 19:12
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.

3 participants