Skip to content

fix(replay): fix playback stopping when skipping backwards with virtual DOM#1806

Open
d0ugal wants to merge 3 commits intorrweb-io:masterfrom
d0ugal:fix/virtual-dom-backward-skip
Open

fix(replay): fix playback stopping when skipping backwards with virtual DOM#1806
d0ugal wants to merge 3 commits intorrweb-io:masterfrom
d0ugal:fix/virtual-dom-backward-skip

Conversation

@d0ugal
Copy link
Copy Markdown

@d0ugal d0ugal commented Mar 18, 2026

Summary

When useVirtualDom is enabled (the default), skipping backwards in a replay could cause playback to stop entirely.

destroyTree() was called before legacy missing nodes were resolved, resetting the virtual DOM mirror. Subsequent createOrGetNode() and diff() calls used the empty mirror, producing nodes with -1 IDs that were never added to the real DOM mirror.

The fix moves destroyTree() after the legacy missing nodes loop so the virtual DOM mirror is still available when converting legacy nodes.

This may also fix #1358.

Future improvement

The style mutation application (constructedStyleMutations and adoptedStyleSheets) in the Flush handler is not wrapped in try/catch. An exception there would propagate up and prevent timer.start() from executing, also stopping playback. Adding try/catch (matching the pattern used elsewhere in the handler) would improve resilience.

Disclosure

Claude was used to help with this change but it was manually verified.

Test plan

  • Manually tested with a real-world recording from the OpenTelemetry demo app that previously exhibited this bug
  • Existing test suite passes

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 18, 2026

🦋 Changeset detected

Latest commit: d42e107

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

This PR includes changesets to release 19 packages
Name Type
rrweb Patch
rrweb-snapshot 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

@d0ugal d0ugal force-pushed the fix/virtual-dom-backward-skip branch 2 times, most recently from eb1db3b to 4062ab9 Compare March 18, 2026 12:53
…al DOM

When using the virtual DOM (useVirtualDom: true), skipping backwards
could cause playback to stop entirely.

destroyTree() was called before legacy missing nodes were resolved,
resetting the virtual DOM mirror. Subsequent createOrGetNode() and
diff() calls used the empty mirror, producing nodes with -1 IDs
that were never added to the real DOM mirror.

Move destroyTree() after the legacy missing nodes loop so the virtual
DOM mirror is still available when converting legacy nodes.
@d0ugal d0ugal force-pushed the fix/virtual-dom-backward-skip branch from f5c689e to 5a99ce0 Compare March 18, 2026 12:56
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.

[Bug]: rrweb-player cannot display dynamically inserted DOM nodes when jumping to a certain moment.

1 participant