Skip to content

Error not captured by sentry: Invalid request method "OPTIONS" #7185

@alexblack

Description

@alexblack

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g. bundle.tracing.min.js) in your SDK setup.

@sentry/remix

SDK Version

7.34.0

Framework Version

Remix 1.8.2

Link to Sentry event

No response

SDK Setup

Here is our remix server sentry init:

  init({
    beforeSend,
    sendDefaultPii: true,
    dsn: SENTRY_ADDON_DSN,
    tracesSampleRate: getApp() === 'syncwith' ? 1 : 0.05,
    normalizeDepth: 6, // stringify deeper objects
    integrations: [
      // enable HTTP calls tracing
      new Integrations.Http({ tracing: true }),
      new Integrations.RequestData({
        include: {
          ip: true,
        },
      }),
    ],
  });

Also:

const createSentryRequestHandler =
  wrapExpressCreateRequestHandler(createRequestHandler);

And:

export default withSentry(App);

Steps to Reproduce

Remix has a regression where it fails to handle OPTIONS requests, and I expected/hoped Sentry would have alerted us to this, instead we didn't get an errors tracked, and hence no alerts or notifications.

In our http logs I see:

Feb 14 11:06:48 AM  ErrorResponse {
Feb 14 11:06:48 AM    status: 405,
Feb 14 11:06:48 AM    statusText: 'Method Not Allowed',
Feb 14 11:06:48 AM    internal: true,
Feb 14 11:06:48 AM    data: 'Error: Invalid request method "OPTIONS"',
Feb 14 11:06:48 AM    error: Error: Invalid request method "OPTIONS"
Feb 14 11:06:48 AM        at getInternalRouterError (/opt/render/project/src/node_modules/@remix-run/router/router.ts:3048:5)
Feb 14 11:06:48 AM        at Object.queryRoute (/opt/render/project/src/node_modules/@remix-run/router/router.ts:2042:13)
Feb 14 11:06:48 AM        at handleResourceRequestRR (/opt/render/project/src/node_modules/@remix-run/server-runtime/dist/server.js:271:40)
Feb 14 11:06:48 AM        at requestHandler (/opt/render/project/src/node_modules/@remix-run/server-runtime/dist/server.js:47:24)
Feb 14 11:06:48 AM        at /opt/render/project/src/node_modules/@remix-run/express/dist/server.js:39:28
Feb 14 11:06:48 AM        at /opt/render/project/src/node_modules/@sentry/src/utils/serverAdapters/express.ts:85:1
Feb 14 11:06:48 AM        at Layer.handle [as handle_request] (/opt/render/project/src/node_modules/express/lib/router/layer.js:95:5)
Feb 14 11:06:48 AM        at next (/opt/render/project/src/node_modules/express/lib/router/route.js:144:13)
Feb 14 11:06:48 AM        at next (/opt/render/project/src/node_modules/express/lib/router/route.js:140:7)
Feb 14 11:06:48 AM        at next (/opt/render/project/src/node_modules/express/lib/router/route.js:140:7)
Feb 14 11:06:48 AM  }

Here is the PR where Remix fixed the issue: remix-run/react-router#9914

Expected Result

I expected this error to be caught by sentry so we could be alerted about it. Is there something we need to change in our config to handle this?

Actual Result

No warnings or alerts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: remixIssues related to the Sentry Remix SDKStale

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions