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

Gatsby: Sentry.captureException() doesn't work unless reinitialized

Open JordanVincent opened this issue 2 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • [X] I have reviewed the documentation https://docs.sentry.io/
  • [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/gatsby

SDK Version

7.12.1

Framework Version

Gatsby 4.14.1

Link to Sentry event

No response

Steps to Reproduce

Initialize the plugin in gatsby-config.js:

module.exports = {
  plugins: [
    {
      resolve: '@sentry/gatsby',
      options: {
        dsn: 'XXXX',
      },
    },
  ],
}

On the client (e.g. inside a component):

import * as Sentry from '@sentry/gatsby';
Sentry.captureException(new Error('error');

Expected Result

An exception should be sent to Sentry.

Actual Result

Nothing is sent to Sentry (nothing at sentry.io or in the browser's network tab) unless calling Sentry.init({ dns: 'XXXX' }) before calling Sentry.captureException(). Unhandled exceptions are properly captured, but not manual calls to Sentry.captureException().

JordanVincent avatar Sep 12 '22 21:09 JordanVincent

Hey, thanks for writing in! Does this also happen when using a sentry.config.js file as per https://docs.sentry.io/platforms/javascript/guides/gatsby/#sentry-configuration-file?

AbhiPrasad avatar Sep 13 '22 13:09 AbhiPrasad

Same thing with sentry.config.js. However, I tried downgrading to 6.19.7 and it worked! So version 7 may have introduced a breaking change.

JordanVincent avatar Sep 13 '22 21:09 JordanVincent

Ah yes we did do this - https://github.com/getsentry/sentry-javascript/pull/4857, but not sure why manual calls are not working.

Will backlog, but PRs are welcome for anyone who would like to help out!

AbhiPrasad avatar Sep 14 '22 08:09 AbhiPrasad

I can't reproduce it. Can I get detailed configuration files?

outsideris avatar Oct 02 '22 07:10 outsideris

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 label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


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

github-actions[bot] avatar Mar 25 '23 00:03 github-actions[bot]

Same thing is happening with Next.js.

moy2010 avatar Jul 19 '23 23:07 moy2010

@moy2010, please open a GH issue and fill out a new bug report, we'll take a look!

AbhiPrasad avatar Jul 24 '23 16:07 AbhiPrasad