Skip to content

Commit 2d69912

Browse files
authored
fix(replay): Adjust development hydration error messages (#9922)
Refine the regex to match fewer errors, seeing some false positives in replays that are not hydration errors. fixes getsentry/sentry#61943
1 parent c85b2e4 commit 2d69912

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/replay/src/coreHandlers/handleBeforeSendEvent.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ function handleHydrationError(replay: ReplayContainer, event: ErrorEvent): void
3131
// Example https://reactjs.org/docs/error-decoder.html?invariant=423
3232
exceptionValue.match(/reactjs\.org\/docs\/error-decoder\.html\?invariant=(418|419|422|423|425)/) ||
3333
// Development builds of react-dom
34-
// Example Text: content did not match. Server: "A" Client: "B"
35-
exceptionValue.match(/(hydration|content does not match|did not match)/i)
34+
// Error 1: Hydration failed because the initial UI does not match what was rendered on the server.
35+
// Error 2: Text content does not match server-rendered HTML. Warning: Text content did not match.
36+
exceptionValue.match(/(does not match server-rendered HTML|Hydration failed because)/i)
3637
) {
3738
const breadcrumb = createBreadcrumb({
3839
category: 'replay.hydrate-error',

packages/replay/test/integration/coreHandlers/handleBeforeSendEvent.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ describe('Integration | coreHandlers | handleBeforeSendEvent', () => {
2727
const addBreadcrumbSpy = jest.spyOn(replay, 'throttledAddEvent');
2828

2929
const error = Error();
30-
error.exception.values[0].value = 'Text content did not match. Server: "A" Client: "B"';
30+
error.exception.values[0].value =
31+
'Text content does not match server-rendered HTML. Warning: Text content did not match.';
3132
handler(error);
3233

3334
expect(addBreadcrumbSpy).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)