sentry-javascript: Sentry 7.73.0 causes `styled-components` to fail to render with styles/CSS
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
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
- 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:
- 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.
- The webapp built - and deployed and we noticed that UI components from the Grommet library no longer showed properly.
- 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
- 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);
}
- Now the webapp loads and renders Grommet ui components as expected:
- 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
- fix(replay): Fix potential broken CSS in styled-components NOTE: This requires a bump to rrweb library Fixes an issue where the Replay integration can potentially break applications that use `styled... — committed to getsentry/sentry-javascript by billyvg 9 months ago
- fix(replay): Fix potential broken CSS in styled-components NOTE: This requires a bump to rrweb library Fixes an issue where the Replay integration can potentially break applications that use `styled... — committed to getsentry/sentry-javascript by billyvg 9 months ago
- fix(replay): Fix potential broken CSS in styled-components (#9234) Fixes an issue where the Replay integration can potentially break applications that use `styled-components`. `styled-components` [r... — committed to getsentry/sentry-javascript by billyvg 9 months ago
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.
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 🤔
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.0and use Session Replay withSentry.Replay()does the UI components work fine? If so, this is probably due to the rrweb upgrade in in7.73.0. Something we need to take a look at.cc @billyvg.