Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 33 additions & 10 deletions docs/platforms/javascript/guides/react-router/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,11 @@ Update your `entry.server.tsx` file:
+ createReadableStreamFromReadable,
+});

export default handleRequest;

export const handleError: HandleErrorFunction = (error, { request }) => {
// React Router may abort some interrupted requests, don't log those
if (!request.signal.aborted) {
+ Sentry.captureException(error);
// optionally log the error so you can see it
console.error(error);
}
};
export default handleRequest;

+export const handleError = Sentry.createSentryHandleError({
+ logErrors: false
+});

// ... rest of your server entry
```
Expand Down Expand Up @@ -369,6 +363,35 @@ export default wrapSentryHandleRequest(handleRequest);

</Expandable>

<Expandable title="Do you need to customize your handleError function?">
If you have custom logic in your `handleError` function, you'll need to capture errors manually:

```tsx {12}
import {
getMetaTagTransformer,
wrapSentryHandleRequest,
} from "@sentry/react-router";
// ... other imports

export function handleError(
error: unknown,
{
request,
params,
context,
}: LoaderFunctionArgs | ActionFunctionArgs
) {
if (!request.signal.aborted) {
Sentry.captureException(error);
console.error(formatErrorForJsonLogging(error));
}
}

// ... rest of your entry.server.ts file
```

</Expandable>

### Update Scripts

Since React Router is running in ESM mode, you need to use the `--import` command line options to load our server-side instrumentation module before the application starts.
Expand Down