getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.94k stars 1.56k forks source link

Getting `TypeError: utils.getGlobalSingleton is not a function` error #5295

Closed zeckdude closed 2 years ago

zeckdude commented 2 years ago

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/nextjs

SDK Version

^7.2.0

Framework Version

^7.2.0

Link to Sentry event

No response

Steps to Reproduce

  1. Follow install steps at https://docs.sentry.io/platforms/javascript/guides/nextjs/#install
  2. Start app
  3. See following error in terminal
    unhandledRejection: TypeError: utils.getGlobalSingleton is not a function

Expected Result

The app should start normally without an error

Actual Result

Shown in terminal and blocking app from starting:

unhandledRejection: TypeError: utils.getGlobalSingleton is not a function
AbhiPrasad commented 2 years ago

Hi @zeckdude, thanks for opening an issue! Do you mind if you could provide some of the info that was asked in https://github.com/getsentry/sentry-javascript/pull/4860#issuecomment-1163546404:

  1. the output of npm ls @sentry/utils and npm ls @sentry/nextjs (if you're using yarn, yarn why @sentry/utils and yarn why @sentry/nextjs works just as well!)
  2. what version of the SDK you are installing
  3. Details about your environment - using npm/yarn/pnpm (and version), node version etc.
  4. What version of NextJS you are running
  5. Your webpack version

Also would be helpful would be your package.json (specifically your deps and dev deps).

AbhiPrasad commented 2 years ago

I'm unable to reproduce the error you've got. Here's the steps I took:

  1. I ran yarn create next-app to install a fresh NextJS installation with NextJS v12 and Webpack 5
  2. I went into the next app directory and ran yarn add @sentry/nextjs which installed Sentry NextJS SDK v7.2.0
  3. I used the wizard to install Sentry, running npx @sentry/wizard -i nextjs, and changed the SENTRY_DSN to use a environmental variable as per: https://nextjs.org/docs/basic-features/environment-variables
  4. I started the dev server with yarn dev and saw no errors on the console. I also ran yarn build and saw no errors.

Does that sounds similar to what you did?

Here is an example repo that resulted from following the steps above: https://github.com/AbhiPrasad/gh-5295-nextjs-getGlobalSingleton

zeckdude commented 2 years ago

@AbhiPrasad I really appreciate your prompt attention. I'm not sure why that error appeared but after I downgraded to version 6 and then added the latest again, it worked fine now. I'll close the issue.