Using Replay to Solve Hydration Errors #62097
Replies: 5 comments 6 replies
-
This would be so lovely to have... in Remix. 😅 |
Beta Was this translation helpful? Give feedback.
-
We've published a changelog with how to get started debugging hydration errors using session replay https://changelog.getsentry.com/announcements/diff-hydration-errors-with-replay |
Beta Was this translation helpful? Give feedback.
-
This has the makings of a super useful feature, thank you! 🙏 One thing we have noticed at a glance is that differences in attribute order are highlighted in the diff. For example: (Note that this is just a one-line snippet of a much larger diff. And in this case the particular line comes from framework code, not app code.) I stand to be corrected on this but I don't believe React cares about attribute order, in terms of a hydration mismatch. So you get a little visual noise from these if you're looking at a relatively larger/longer diff. Wish list item: for only missing/new attributes or differing attribute values, to be highlighted, and for attribute order (where the attribute and value are otherwise identical) to be ignored. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Good news everyone, we've moved this feature into GA today! Every Sentry org will be able to install the Replay integration and have Hydration Errors captured automatically. Make sure you're on SDK version 7.87.0 or higher. https://sentry.io/changelog/debug-hydration-errors-with-our-diff-tool---now-generally-available/ |
Beta Was this translation helpful? Give feedback.
-
Introduction
Hydration Errors are quite common yet hard to fix. They happen when the HTML in the first render cycle doesn't match the HTML sent by the server. It causes both a full re-render can sometimes can cause adverse side effects. Currently, hydration errors are being filtered out by Sentry's inbound filters because Sentry cannot give helpful debugging information and they are very noisy. Our goal is to make hydration errors actionable so developers can actually fix them.
Using Session Replay
We can use session replays to display a visual and html diff of when the app starts up. Because we're filtering out the error events we've added an additional
replay.hydrate-error
breadcrumb to the Replay SDK to record when these errors occur, similar to a click event.Once we have the hydration error breadcrumb, we can get the initial pageload and compare it with the html state at the time of the
replay.hydrate-error
event. Comparing these visually and using an html diff it should point people into the right direction of the hydration error's source.We'd love to hear from you on:
Getting Started
See this changelog for notes on how to get started https://changelog.getsentry.com/announcements/diff-hydration-errors-with-replay
Beta Was this translation helpful? Give feedback.
All reactions