getsentry / sentry-docs

Sentry's documentation (and tools to build it)
https://docs.sentry.io
Other
323 stars 1.38k forks source link

Incomplete React Router documentation #9337

Open Zwyx opened 4 months ago

Zwyx commented 4 months ago

Core or SDK?

Platform/SDK

Which part? Which one?

JavaScript React

Description

When using React Router v6, setting up Sentry as recommended in the Getting started page is not enough to catch errors: any error happening in a route will be caught by React Router and not transmitted to Sentry.

Note: this only happens when the app is compiled. It does not happen in development mode, because React rethrows errors caught within an error boundary. So, if you test Sentry in development, you might think Sentry works correctly and catches all errors. But once in production, it won't work anymore!

Suggested Solution

The only way I made it work was using a solution provided by another user here.

getsantry[bot] commented 4 months ago

Assigning to @getsentry/support for routing ⏲️

Zwyx commented 4 months ago

I would add that the workaround provided in the linked discussion doesn't allow to use the Sentry crash-report modal, which is usually done with the showDialog prop:

<Sentry.ErrorBoundary fallback={...} showDialog>
  ...
</Sentry.ErrorBoundary>