nuxt-community / sentry-module

Sentry module for Nuxt 2
https://sentry.nuxtjs.org
MIT License
501 stars 114 forks source link

Fix stacktrace and source maps for servedside #184

Open iliyaZelenko opened 4 years ago

iliyaZelenko commented 4 years ago

What problem does this feature solve?

It will not be necessary to use $sentry.captureException(error) to catch an error everywhere as described here, each error will be logged itself if it appears in asyncData.

What does the proposed changes look like?

I want the error to be caught through this module, for example, in this code:

async asyncData ({ params }) {
  if (params.id === '123') throw Error('Test error')

  someFunctionThatCanThrowError()
}

That is, not to write like this:

async asyncData ({ params }) {
  if (params.id === '123') {
    $sentry.captureException(Error('Test error'))
  }

  try {
    someFunctionThatCanThrowError()
  } catch (e) {
    $sentry.captureException(e)
  }
}
This feature request is available on Nuxt community (#c97)
rchl commented 4 years ago

I think the exception will be caught regardless.

The linked example is probably just an example of usage and an example of how to capture the exception and not make the page crash.

Do you actually have an issue with exceptions not being captured from asyncData?

iliyaZelenko commented 4 years ago

I was my mistake, in fact it seems to work.

I have another problem: the stacktrace in such an error looks very strange. I use souremaps, if an error occurs on the client side, then I can clearly see stacktrace.

Error in asyncData:

image

Error on client side:

image

As you can see, on client side the stacktrace is clear, I can understand where the error occurred, on the server side everything is different. Are there any ways to improve this?

rchl commented 4 years ago

Yes, I think I might have had issues with that too (don't get server-side errors often so didn't bother analyzing).

I think it's a matter of either:

I'd need to analyze this at some point but any help is welcome.

iliyaZelenko commented 4 years ago

This will very-very help in debugging errors, I have a lot of code on the server side and it is not possible to transfer it to the client side in order to finally see sourcemaps. I look forward to news on this topic, keep me posted. Thanks for the quick answers!

How i use module:

      ['@nuxtjs/sentry', {
        publishRelease: true,
        webpackConfig: {
          silent: [process.env.IS_PROD, process.env.IS_TESTBB].includes('true')
        }
      }],

Also i have scuh env variables:

SENTRY_DSN=***
SENTRY_AUTH_TOKEN=***
SENTRY_ORG=sentry
SENTRY_PROJECT=***
# this defaults to https://sentry.io/.
SENTRY_URL=http://sentry.testbb.ru
rchl commented 4 years ago

I forgot to post here it seems but the issue is partially analyzed and seems a bit hard to fix without changes in Nuxt. See https://github.com/nuxt/nuxt.js/issues/7461 which talks about just local server-side debugging with source maps but it should be relevant.

(There is a chance that those issues are not related.)

BenjaminGK commented 9 months ago

@rchl any updates on this issue? We are facing this issue as well. We have a single sentry project where we send both node and JS issues to. We are using the latest version of the module but even though we specify in the publishRelease section the release name to be 'project@versionNumber' I can see in the sentry release file generated in The nuxt folder shows a sha key or similar.

rchl commented 9 months ago

Doesn't seem like a related issue (not creating releases properly vs. not able to see proper stack traces on server).

Sounds like a configuration issue. Create a new issue or discussion with all the details.