Skip to content

Remix SDK not reporting server errors to Sentry #6951

Closed
@oliversong

Description

@oliversong

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/remix

SDK Version

7.33.0

Framework Version

1.8.2

Link to Sentry event

No response

SDK Setup

AFAICT, I've set up our code exactly as in the documentation and example vanguard app.

entry.client.tsx

Sentry.init({
  dsn: (window as any).ENV.SENTRY_DSN,
  environment: (window as any).ENV.NODE_ENV,
  tracesSampleRate: 1,
  integrations: [
    new Sentry.BrowserTracing({
      routingInstrumentation: Sentry.remixRouterInstrumentation(
        useEffect,
        useLocation,
        useMatches
      ),
    }),
  ],
});
entry.server.tsx

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  environment: process.env.NODE_ENV,
  tracesSampleRate: 1,
  integrations: [new Sentry.Integrations.Prisma({ client: prisma })],
});
root.tsx

export default withSentry(App);

I've double checked that the environment variables are being passed correctly on both the client and the server init calls.

Steps to Reproduce

  1. Load the app
  2. Purposely cause a client side error as suggested by the documentation:
<button
  type="button"
  onClick={() => {
    throw new Error("Sentry Frontend Error");
  }}
>
  Throw error
</button>
  1. Purposely cause a server side error as suggested by the documentation
export const action: ActionFunction = async ({ request }) => {
  throw new Error("Sentry Error");
};

Expected Result

Errors should show up in Sentry for both of these.

Actual Result

Error only appears for the client side error. The server side error never appears.

If I set an explicit captureException call in the error boundary in root.tsx, then that will be reported and show in Sentry.

export function ErrorBoundary({ error }: { error: any }) {
  Sentry.captureException(error);
  return (
    <html>
      <head>
        <title>Oh no!</title>
        <Meta />
        <Links />
      </head>
      <body>
        <Layout style={{ height: "100%" }}>
          <Header />
          <Layout className="ContentContainer">
            <Card>
              <h1>
                <WarningOutlined /> An error occurred - please try again.
              </h1>
            </Card>
          </Layout>
          <Footer />
        </Layout>
        <Scripts />
      </body>
    </html>
  );
}

I've also tried removing the error boundary in root.tsx entirely (thinking it may be conflicting), to no avail.
For whatever reason, I just cannot get sentry's default instrumentation on the server side to function at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: remixIssues related to the Sentry Remix SDK

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions