- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.7k
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nuxt
SDK Version
9.0.1
Framework Version
Nuxt 3.15.1, aws-lambda
Link to Sentry event
No response
Reproduction Example/SDK Setup
Sentry.init({
    dsn: process.env.SENTRY_DSN,
    environment: process.env.APP_ENV || 'development',
    normalizeDepth: 10,
    beforeSend: async (event, hint) => {
      console.log("before send", event, hint)
      const error = hint.originalException
      if (!event.contexts) {
        event.contexts = {}
      }
      if (error && (error instanceof H3Error || isFetchError(error))) {
        if (error instanceof FetchError) {
          if (
            /^https:\/\/api\.cloudflare\.com/.test(
              error.request?.toString() || ''
            ) ||
            [402, 403, 404, 422].includes(error.statusCode || 0)
          ) {
            return null
          } else if (
            [401].includes(error.statusCode || 0) &&
            error.statusMessage ===
              'The user does not have an active session or is not authenticated'
          ) {
            return null
          }
        }
        if (
          ['This URL can be used only once', 'Access expired.'].includes(
            error.data.error_description
          )
        ) {
          return null
        }
        event.contexts.error_data = { error_data: error.data }
      }
      return event
    }
  })
})Steps to Reproduce
I switched from something based on this manual integration to the provided Nuxt module, and suddenly I was not getting any errors being reported.
At first, I thought this was just a result of this block dropping all 3xx and 4xx errors.
While that is a separate issue (that should either pass everything through to be filtered by beforeSend() or able to be customized through options on the module), I found that it wasn't the (only) cause of my issue, as triggering a 503 error still didn't send anything.
Expected Result
I expected that I would get errors reported in Sentry as I had before.
Actual Result
Still no errors being logged in Sentry from the server.
While debugging, I basically just copied the hook code from the official module into my own nitro hook and made that one ignore anything not 3xx or 4xx errors as the original Sentry plugin will handle those, and my code won't cause duplicates.
However, while I can confirm the init() is run (using NODE_OPTIONS to --import .output/server/sentry.server.config.mjs as per the AWS Lambda ESM docs), and there is a client, Sentry.captureException(error) does not appear to actually ever report anything in Sentry. It seems that I am seeing some "Too Large" errors according to my stats page, but I don't think they correspond to the tests I've been doing (hard to prove definitively without a filter for environment).
Maybe related: is there a reason why every chunk now has tons of extra code in it? This ballooned my deployed code from ~19MB to ~46MB. I did add ignoreInternal: false to attempt to confirm if it was triggering the "Too Large" error, but I'm not sure that would actually log the internal Sentry error given how nitro hooks work. Either way, I don't know how an endpoint that just does throw createError({ statusCode: 503, statusMessage: "Fake Error" }) would be hitting those limits.
For now, I'm going to revert things. While this issue doesn't have aws-lambda on it, I assumed it would be fine since it is just Node (and there is a separate AWS Lambda integration). But maybe not.
Metadata
Metadata
Assignees
Labels
Projects
Status