Skip to content

Add a breadcrumb when a hydration error happens #9649

Closed

Description

@bruno-garcia

Context

This came out of a discussion internally about possible ways to help developers using Next.js (and possibly other frameworks like Remix, SvelteKit, etc) identify the root cause of hydration errors.

Currently, after several users complained about these errors not being actionable, Sentry is dropping them server-side, by default. Users can opt-out of this server-side filter under Project Settings, Inbound Filters:

image

Improvement

The goal is to use Replay to help users. As a first step, we'd like to add a breadcrumb to Replays so we know when the hydration error happens. This won't affect the default server-side filter mentioned above.

Ideas from @ryan953:

To 100% validate that the replay data helps with hydration errors we wouldn’t even need to build out the service to start. We could add hydration errors as breadcrumbs to the replay (instead of proper errors, which we do want obvs) and do the highlighting when the replay details page is viewed. Probably wouldn’t ship that, but it would give us a visualization in a matter of hours.

Activity

  1. AbhiPrasad commented on Nov 23, 2023

    @AbhiPrasad
    Contributor

    We add breadcrumbs whenever we capture Sentry events

    client && client.on && client.on('beforeSendEvent', addSentryBreadcrumb);

    Can replay pick this up?

  2. bruno-garcia commented on Nov 23, 2023

    @bruno-garcia
    MemberAuthor

    @AbhiPrasad how can we tell if that event captured was out of a hydration error?

  3. AbhiPrasad commented on Nov 23, 2023

    @AbhiPrasad
    Contributor
  4. bruno-garcia commented on Nov 23, 2023

    @bruno-garcia
    MemberAuthor

    That makes sense, looks promising! Are the crumbs written synchronously, as the error is detected? Could we expect that timestamp to represent precisely when the problem was detected?

  5. AbhiPrasad commented on Nov 23, 2023

    @AbhiPrasad
    Contributor

    That makes sense, looks promising! Are the crumbs written synchronously, as the error is detected? Could we expect that timestamp to represent precisely when the problem was detected?

    They are written after event processors apply and before beforeSend. These are all sync though so the timestamp skew should be minimal. We can test it out though to confirm.

    If thats not acceptable, we can come back and re-adjust how breadcrumbs get emitted.

  6. ryan953 commented on Nov 23, 2023

    @ryan953
    Member

    @AbhiPrasad i think we're going to need to write that breadcrumb into the replay event stream. @billyvg @mydea @lforst would know the details with confidence.

  7. added a commit that references this issue on Dec 12, 2023
    a05de17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions