Skip to content

fix(rrweb-snapshot): inserting doctype element #1711

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 2 commits into
base: master
Choose a base branch
from

Conversation

JonaszJestem
Copy link

@JonaszJestem JonaszJestem commented Jul 1, 2025

In some rare cases I've noticed that during replay I do get an error in this specific case. It fails with:

HierarchyRequestError: Failed to execute 'appendChild' on 'Node': Can't insert a doctype after the root element
  at buildNodeWithSN
  at rebuild
  at Ya.rebuildFullSnapshot
  at castFn
  at wrappedCastFn
  at Ya.<anonymous>
  at play

Copy link

changeset-bot bot commented Jul 1, 2025

🦋 Changeset detected

Latest commit: 9c2bcb4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
rrweb-snapshot Patch
rrweb Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/all Patch
@rrweb/replay Patch
@rrweb/record Patch
@rrweb/types Patch
@rrweb/packer Patch
@rrweb/utils Patch
@rrweb/web-extension Patch
rrvideo Patch
@rrweb/rrweb-plugin-console-record Patch
@rrweb/rrweb-plugin-console-replay Patch
@rrweb/rrweb-plugin-sequential-id-record Patch
@rrweb/rrweb-plugin-sequential-id-replay Patch
@rrweb/rrweb-plugin-canvas-webrtc-record Patch
@rrweb/rrweb-plugin-canvas-webrtc-replay Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@JonaszJestem JonaszJestem marked this pull request as ready for review July 1, 2025 12:08
@eoghanmurray
Copy link
Contributor

The test case you have added has the doctype out of order. Was this a real world example, or is this a synthetic example to trigger the case?
I'm asking as it might be something we should also be fixing at record time if snapshot.ts is generating things in an out of order way.
Other possibility is that you are experiencing doctype added by a mutation?

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.

2 participants