Issue
Before I added Sentry to my Remix app, server errors logged to the console with console.error. After I integrated @sentry/remix, those errors still reach Sentry, but they no longer print to my server console.
Applies To
All SaaS Customers and Self-Hosted Users
@sentry/remixhandleErrorinentry.server.tsxError Monitoring
Resolution
Remix logs server errors with console.error only when you do not export a custom handleError. When you export handleError (including Sentry.sentryHandleError or a Sentry-wrapped handler), Remix turns off that default console logging. Sentry’s sentryHandleError reports the error to Sentry and does not call console.error.
To keep console logging and Sentry capture:
Open
app/entry.server.tsx(orentry.server.js).Wrap a custom handler with
Sentry.wrapHandleErrorWithSentry.Call
console.errorin that handler (skip aborted requests).
import * as Sentry from "@sentry/remix";export const handleError = Sentry.wrapHandleErrorWithSentry(
(error, { request }) => {
if (!request.signal.aborted) {
console.error(error);
}
},
);
If you currently export only Sentry.sentryHandleError, replace it with the wrapped handler above so you can add console logging.
