Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot assign to read only property 'debug' of object '#<Object>' #14368

Closed
3 tasks done
egorshar opened this issue Nov 19, 2024 · 4 comments · Fixed by #14402
Closed
3 tasks done

Cannot assign to read only property 'debug' of object '#<Object>' #14368

egorshar opened this issue Nov 19, 2024 · 4 comments · Fixed by #14402
Assignees
Labels
Package: react Issues related to the Sentry React SDK

Comments

@egorshar
Copy link

egorshar commented Nov 19, 2024

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/react

SDK Version

8.30.0

Framework Version

18.2.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

initSentry({
  ...runtimeConfig.sentry,
  allowUrls: [
    document.location.origin,
    ...(appSettings.themeBuild.assetPrefix ? [appSettings.themeBuild.assetPrefix] : []),
  ],
  environment: runtimeConfig.env,
  integrations: [
    reactRouterV6BrowserTracingIntegration({
      stripBasename: true,
      useEffect,
      useLocation,
      useNavigationType,
      createRoutesFromChildren,
      matchRoutes,
    }),
    replayIntegration(),
    httpClientIntegration(),
  ],
  tracesSampleRate: 1.0,
  tracePropagationTargets: ['localhost', API_REGEXP],
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
});

Steps to Reproduce

In exceptions reported by our clients, we observe an error where Sentry’s breadcrumbs integration seems to overwrite the console.debug method, but the method is unexpectedly readonly. This issue occurs before the full initialization of the Sentry client, and as a result, the events are not enriched with even basic browser metadata. Despite searching for similar issues, no solutions or explanations have been found online.

Do you have any insights into what might cause this or suggestions on how best to handle this case?

Expected Result

No error should be thrown

Actual Result

TypeError
Cannot assign to read only property 'debug' of object '#'

Image

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Nov 19, 2024
@github-actions github-actions bot added the Package: react Issues related to the Sentry React SDK label Nov 19, 2024
@lforst
Copy link
Member

lforst commented Nov 19, 2024

Thanks for writing in. We are patching the console object which normally is writable. Would you mind checking your codebase for any code that may make the consol object readonly (ie, frozen or writable: false or similar)?

@egorshar
Copy link
Author

We observe this error occurring for approximately 1% of users (based on sentry transactions), while the rest use the site without such issues. This makes it seem unlikely that the problem lies in our code.

Initially, we considered potential causes like browser extensions or Google Tag Manager (GTM). However, GTM is loaded after the application’s initialization, so it’s unlikely to be the source. Regarding browser extensions, we cannot confirm since we lack metadata about them in Sentry. Additionally, most of our traffic comes from mobile devices rather than desktops, which reduces the likelihood of extension-related issues.

Currently, our plan is to wrap the Sentry initialization in a try/catch block and attempt to manually send the error data if the initialization fails.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Nov 20, 2024
@mydea mydea self-assigned this Nov 21, 2024
@mydea
Copy link
Member

mydea commented Nov 21, 2024

Although the problem here is likely something other then the Sentry SDK, it does not hurt for us to handle this more gracefully and do not throw an error if we encounter such a problem! We'll try to adjust the SDK accordingly.

mydea added a commit that referenced this issue Nov 21, 2024
This PR adds a guard to avoid us throwing if we try to fill a readonly
property on an object.

Generally speaking this should not work, but it does not hurt us to be
defensive here and try-catch this to avoid breaking users apps.

Fixes #14368
Copy link
Contributor

A PR closing this issue has just been released 🚀

This issue was referenced by PR #14402, which was included in the 8.40.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: react Issues related to the Sentry React SDK
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants