Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
alexblack opened this issue Feb 14, 2023 · 4 comments
Closed
3 tasks done

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

alexblack opened this issue Feb 14, 2023 · 4 comments
Labels
Package: remix Issues related to the Sentry Remix SDK Stale

Comments

@alexblack
Copy link

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.

@AbhiPrasad
Copy link
Member

If Remix themselves handled this exception and swallowed it there at the current moment there is no way for Sentry to capture it - so it depends on what the framework was doing with the error internally. I assume this was not a unhandled exception (which would crash the server).

I agree though we should be capturing these, maybe we can monkey patch getInternalRouterError?

@AbhiPrasad AbhiPrasad added Type: Feature Package: remix Issues related to the Sentry Remix SDK and removed Type: Bug Status: Untriaged labels Feb 15, 2023
@alexblack
Copy link
Author

You're right it didn't crash the server, so I do think it was unhandled.

I do see Sentry in that call stack... That might mean Sentry would/could have seen it?

@AbhiPrasad
Copy link
Member

You're right it didn't crash the server, so I do think it was unhandled.

I do see Sentry in that call stack... That might mean Sentry would/could have seen it?

Yes - let's see if I can quick win handle this case, otherwise will backlog for later.

@getsantry
Copy link

getsantry bot commented May 16, 2024

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label May 16, 2024
@getsantry getsantry bot closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: remix Issues related to the Sentry Remix SDK Stale
Projects
Archived in project
Development

No branches or pull requests

3 participants