GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(snapshot): Clear leftover nodes when `document.open()` is skipped by sentry-junior[bot] · Pull Request #350 · getsentry/rrweb

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 28, 2026 •
edited by gggritso
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The replay player crashes with a HierarchyRequestError while it appends the full snapshot's doctype. The error seems to be from trying to jam multiple DOCTYPE declarations into the same iframe.

Before building a document, buildNodeWithSN calls doc.close(); doc.open() and expects doc.open() to clear the iframe. Browsers skip open() once the document's parser has been aborted (for example by window.stop()). In that case the previous rebuild stays in the iframe, and appending the new doctype runs into the old <doctype> + <html>.

The fix removes any children left over after open(), so the rebuild always starts from an empty document.

Fixes REPLAY-1031.

via George Gritsouk.

--

View Junior Session [Sentry]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sentry-junior @gggritso
fix(snapshot): Avoid HierarchyRequestError when rebuilding a misplace…
934c030
…d doctype

Full snapshots whose doctype comes after <html>, or that carry a second
doctype (including the one written for BackCompat documents), made
rebuild() throw a HierarchyRequestError and crash the replayer. Insert the
doctype before the root element, or replace the existing one, instead.

Co-Authored-By: George Gritsouk <[email protected]>
@linear-code

linear-code Bot commented Oct 28, 2026

Copy link
Copy Markdown

REPLAY-1031

sentry-junior[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gggritso
gggritso marked this pull request as draft October 28, 2026 18:57
@sentry-junior @gggritso
fix(snapshot): Clear leftover nodes when document.open() is skipped
25a1ffc
The previous doctype-placement change assumed a snapshot with the doctype
after <html>, but a crashing replay has a normal [doctype, html] snapshot.
Both production HierarchyRequestError messages reproduce instead when
document.open() is a no-op because the iframe document's parser was
aborted: the previous rebuild stays in place and the new doctype can't be
appended. Remove any leftover children after open() and revert the
doctype-placement change.

Co-Authored-By: George Gritsouk <[email protected]>
@sentry-junior sentry-junior Bot changed the title fix(snapshot): Avoid HierarchyRequestError when rebuilding a misplaced doctype fix(snapshot): Clear leftover nodes when document.open() is skipped Oct 28, 2026
sentry-junior Bot and others added 2 commits November 6, 2026 21:23
@sentry-junior @gggritso
test(snapshot): Rebuild after the iframe parser was really aborted
0e16900
The existing unit test stubs document.open(). This adds puppeteer tests
that abort the iframe document's parser the way browsers do, with
window.stop() and with a link click that never commits a new document
(a 204), check that open() is now a no-op, and then rebuild. Both fail
with "Can't insert a doctype after the root element" without the fix.

Also drop the changeset, since sentry-v2 no longer uses changesets.

Co-Authored-By: George Gritsouk <[email protected]>
@sentry-junior
Merge branch 'sentry-v2' into fix/rebuild-doctype-placement
0f1071a
@gggritso gggritso changed the title fix(snapshot): Clear leftover nodes when document.open() is skipped fix(snapshot): Clear leftover nodes when document.open() is skipped Nov 6, 2026
gggritso
gggritso reviewed Nov 6, 2026
View reviewed changes
Comment thread packages/rrweb-snapshot/src/rebuild.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/rrweb-snapshot/test/integration.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/rrweb-snapshot/test/integration.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sentry-junior
test(snapshot): Split the parser-abort tests into two cases
21ee16c
Address review feedback: replace the parameterized abort triggers with
two explicit test cases that share setup helpers, drop the leftover
headless comment, and say in rebuild.ts that open() doesn't throw when it
skips clearing the document.
@gggritso

gggritso commented Nov 6, 2026

Copy link
Copy Markdown
Member

@cursor review

cursor[bot] reacted with thumbs up emoji sentry-junior[bot] reacted with eyes emoji
All reactions
  • 👍 1 reaction
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Nov 6, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 21ee16c. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gggritso
gggritso marked this pull request as ready for review November 6, 2026 21:59
logaretm
logaretm approved these changes Nov 9, 2026
View reviewed changes

@logaretm logaretm left a comment

Copy link
Copy Markdown
Member

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.

LGTM, I will handle the compat mode leftover in a separate PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/rrweb-snapshot/src/rebuild.ts
// once the document's parser was aborted (e.g. by window.stop()), open()
// returns without throwing and without clearing the previous rebuild,
// which would make the appends below throw a HierarchyRequestError
while (doc.firstChild) {

@logaretm logaretm Nov 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

nit: This fixes the crash, but leaves out some stale state like compatMode.

It's a very rare case, I had an agent try it in Chromium, after window.stop() a quirks snapshot stays CSS1Compat, and a standards one stays BackCompat if the previous rebuild was quirks.

I can PR that separately once this one merges, probably will try to replace the entire iframe.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gggritso reacted with thumbs up emoji sentry-junior[bot] reacted with eyes emoji
All reactions
  • 👍 1 reaction
  • 👀 1 reaction
@gggritso
gggritso merged commit 49fe3a9 into sentry-v2 Nov 10, 2026
21 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@gggritso
gggritso deleted the fix/rebuild-doctype-placement branch November 10, 2026 03:46
@sentry-junior sentry-junior Bot mentioned this pull request Nov 12, 2026
chore(deps): Bump sentry-javascript to 11.12.0 and rrweb to 2.46.0 getsentry/sentry#130930
Merged
gggritso added a commit to getsentry/sentry that referenced this pull request Nov 12, 2026
@sentry-junior @gggritso
chore(deps): Bump sentry-javascript to 11.12.0 and rrweb to 2.46.0 (#…
af1758a
…130930)

Bumps the Sentry JavaScript SDK from 11.7.0 to
[11.12.0](https://github.com/getsentry/sentry-javascript/releases/tag/11.12.0),
mainly to pick up rrweb
[2.46.0](https://github.com/getsentry/rrweb/releases/tag/2.46.0)
(getsentry/sentry-javascript#26241).

rrweb 2.46.0 fixes:
- Clear leftover nodes when `document.open()` is skipped
(getsentry/rrweb#350)
- Don't record the default value of cleared inputs (getsentry/rrweb#349)
- Keep adopted stylesheets on seek when their first host was removed
(getsentry/rrweb#352)
- Don't throw when tearing down a locked `adoptedStyleSheets` patch
(getsentry/rrweb#351)

Changes:
- `@sentry/browser`, `@sentry/core`, `@sentry/node`, `@sentry/react`:
11.7.0 → 11.12.0 across `static/app`, `static/gsApp`, `static/gsAdmin`,
`static/packages/scraps`, and `tests/js`.
- `@sentry/rrweb`, `@sentry/rrweb-player`, `@sentry/rrweb-snapshot`:
2.45.0 → 2.46.0, so the replay player uses the same rrweb as the SDK.
- `@sentry/rrweb-types`: 2.44.0 → 2.46.0. This drops the duplicate
`@sentry/[email protected]` / `@sentry/[email protected]` entries
from the lockfile.

<!-- junior-request-attribution:start -->
via **George Gritsouk**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AD0AR76A9F5G%3A1794502210.473359 -->

Closes REPLAY-1029
Closes REPLAY-1019

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AD0AR76A9F5G%3A1794502210.473359)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0AR76A9F5G%3A1794502210.473359/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: George Gritsouk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gggritso gggritso gggritso left review comments
@cursor cursor[bot] cursor[bot] left review comments
@logaretm logaretm logaretm approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@gggritso @logaretm
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.