sentry-javascript: Sentry 7.73.0 causes `styled-components` to fail to render with styles/CSS

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

7.73.0

Framework Version

React 17.0.2

Link to Sentry event

No response

SDK Setup

const props = {
    dsn: window.config.sentryDsn,
    environment: window.config.sentryEnv,

    // we are leaving this at zero, so we only record error sessions:
    replaysSessionSampleRate: 0,

    replaysOnErrorSampleRate: 1,

    integrations: [
      new BrowserTracing(),
      new Sentry.Integrations.Breadcrumbs({
        console: false
      }),
      new Sentry.Replay({
        useCompression: false,
        maskAllText: true,
        maskAllInputs: true,
        blockAllMedia: true,
      }),
    ],
    tracesSampleRate: 0.2,
    ignoreErrors: [
      'ResizeObserver loop limit exceeded',
    ],
  };
  try {
    Sentry.init(props);
  } catch (error) {
    console.error('Unable to initialize Sentry', error);
  }

Steps to Reproduce

  1. Our webapp was using Sentry 7.69.0, grommet v2.33.2, grommet-hpe-theme^4.2.0, and everything was working great and Grommet UI components rendered as expected. Here is an example that shows drop down, text input, icons and a data table: image
  2. Renovate overnight created a PR that was auto merged for upgrading @sentry/react and @sentry/tracing from version 7.69.0 to version 7.73.0.
  3. The webapp built - and deployed and we noticed that UI components from the Grommet library no longer showed properly. image
  4. I then went through the motions to upgrade one release at a time from v7.69 --> v7.73.0 - and found out that our webapp worked fine on version 7.72.0 but not on 7.73.0
  5. So, I look at what https://github.com/getsentry/sentry-javascript/releases/tag/7.73.0 contains - and it spoke about Sentry Replay… so I wonder - what happens if I remove replay from our webapp? so I change the Sentry.Init setup to not include Sentry.Replay. This is the adjusted sentry.init logic after removing Sentry.Replay:
const props = {
    dsn: window.config.sentryDsn,
    environment: window.config.sentryEnv,

    // we are leaving this at zero, so we only record error sessions:
    replaysSessionSampleRate: 0,

    replaysOnErrorSampleRate: 1,

    integrations: [
      new BrowserTracing(),
      new Sentry.Integrations.Breadcrumbs({
        console: false
      }),
    ],
    tracesSampleRate: 0.2,
    ignoreErrors: [
      'ResizeObserver loop limit exceeded',
    ],
  };
  try {
    Sentry.init(props);
  } catch (error) {
    console.error('Unable to initialize Sentry', error);
  }
  1. Now the webapp loads and renders Grommet ui components as expected: image
  2. So, with these steps… there is something about Sentry.Replay that is affecting our ui components.

Expected Result

Having Sentry.Replay enabled in v7.73.0 should not affect the webapp ui Grommet Components.

Actual Result

Please see screenshots above (steps to reproduce) where you will see before upgrading to v7.73.0 and after screenshots.

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 4
  • Comments: 19 (8 by maintainers)

Commits related to this issue

Most upvoted comments

We’ve just released v7.74.0 which hopefully fixes this issue! Please let us know if you still run into this after updating. Thanks a lot for the patience, and sorry again for the inconvenience.

We also just hit this issue and had to rollback to 7.72.0. We don’t use Grommet, but we do use Styled Components. I didn’t debug too deeply, but it does look like a bunch of styled components seemed to lose their styling with 7.73.0.

Thanks folks, especially @marksweb for the repro environment – we’ve figured out the issue: in our SDK we were aggressively catching exceptions so that they don’t bubble up into your projects, in doing so we were catching exceptions that the styled-components library was relying when a rule would fail to be inserted (i.e. chrome will throw on unsupported, browser specific pseudo selectors). Any rules following that would fail to be inserted because of an out of bounds index error.

We’ll be releasing a patch for this ASAP. Thanks again for your reports and sorry for the issues this caused.

Hi, I don’t know if this relates to these problems, but after switching to 7.73.0 in my project, many users have such errors due to rrweb. I don’t use SSR.

As far as I can see it does not affect the interface.

…/…/node_modules/@sentry-internal/rrweb/es/rrweb/packages/rrweb/src/record/observer.js in initAdoptedStyleSheetObserver at line 532:1

const originalPropertyDescriptor = Object.getOwnPropertyDescriptor(patchTarget === null || patchTarget === void 0 ? void 0 : patchTarget {snip}

This problem at least should be fixed by: https://github.com/getsentry/rrweb/pull/110, hard to say if that is also the cause of some of the other problems 🤔

Just wanted to +1 this.

Been trying to debug an issue of some styled components not being styled.

We had @sentry/browser 7.73, dropping to 7.72 resolves the issues.

We’re using React 17.0.2, styled-components 5.3.0.

Let me know if I can be of any further use. I took a screen recording of what I was seeing that I was going to send through to my Sentry contact.

Can you send it to me as well please? billy at sentry.io

Can anyone provide an example styled component snippet that is losing its styles? I’ve tested some basic styled components usage and am not able to reproduce the issue.

Thanks – I’ll take a look at this today with a focus on styled-components and SSR.

If you add SDK version 7.72.0 and use Session Replay with Sentry.Replay() does the UI components work fine? If so, this is probably due to the rrweb upgrade in in 7.73.0. Something we need to take a look at.

cc @billyvg.