SIGN IN SIGN UP

fix(replay): guard attachShadow so an unsupported shadow host does not kill playback (#4594)

* fix(replay): guard attachShadow so an unsupported shadow host does not kill playback

The player calls attachShadow on any node marked as a shadow host, in the full
snapshot rebuild and in incremental mutations. Neither site checked that the
rebuilt tag accepts a shadow root, so a host that comes back as a tag the
browser refuses raised a NotSupportedError that escaped unhandled and aborted
the whole rebuild.

Add a shared attachShadowRootSafely helper that reports whether the attach
worked. The rebuild path skips the shadow root; the mutation path skips the
subtree and warns instead of dereferencing a null shadowRoot a line later.

Generated-By: PostHog Desktop
Task-Id: 8948b193-aacc-4857-a0cf-3b37113c8158

* chore(changeset): declare @posthog/rrweb and @posthog/rrweb-snapshot

Declare the packages whose source actually changed. posthog-js bumps
automatically through its workspace:* dependency on @posthog/rrweb.

Generated-By: PostHog Desktop
Task-Id: 8948b193-aacc-4857-a0cf-3b37113c8158

* fix(replay): guard the remaining attachShadow call sites in the player

Guards the rrdom diff and buildFromNode paths, skips a shadow subtree whose host refused a shadow root instead of appending it to the light DOM where its styles would apply document-wide, and adds a lint rule so a new unguarded call site fails lint.

* chore(changeset): release this rrweb fix as a posthog-js patch

packages/rrweb/** is never published; AGENTS.md requires rrweb changes to ship under a posthog-js changeset.

* fix(replay): only skip shadow children when the host refused a shadow root

Gates the skip on the parent being a recorded shadow host, so a recording that never marked one keeps rendering those children in the light DOM.

---------

Co-authored-by: posthog[bot] <206114724+posthog[bot]@users.noreply.github.com>
Co-authored-by: Anna Garcia <anna.g@posthog.com>
Co-authored-by: Tue Haulund <tue@posthog.com>
P
posthog[bot] committed
1d88b4ec30637833bbd0b851843f33913b94b169
Parent: ab1383a
Committed by GitHub <noreply@github.com> on 8/26/2026, 9:17:16 AM