sentry-module icon indicating copy to clipboard operation
sentry-module copied to clipboard

Fix stacktrace and source maps for servedside

Open iliyaZelenko opened this issue 4 years ago • 7 comments

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)

iliyaZelenko avatar May 29 '20 09:05 iliyaZelenko

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?

rchl avatar May 29 '20 09:05 rchl

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?

iliyaZelenko avatar May 29 '20 09:05 iliyaZelenko

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:

  • wrong source map setting for the server build
  • something wrong with matching source-maps on Sentry (possibly due to the module using the wrong prefix)

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

rchl avatar May 29 '20 09:05 rchl

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

iliyaZelenko avatar May 29 '20 10:05 iliyaZelenko

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.)

rchl avatar Jul 24 '20 07:07 rchl

@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.

BenjaminGK avatar Jan 23 '24 01:01 BenjaminGK

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.

rchl avatar Jan 23 '24 09:01 rchl