Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempted import error _optionalChain and _nullishCoalesce on @sentry/nextjs 7.114.0 #11961

Open
3 tasks done
0x33dm opened this issue May 9, 2024 · 5 comments
Open
3 tasks done

Comments

@0x33dm
Copy link

0x33dm commented May 9, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

7.114.0

Framework Version

14.2.3

Link to Sentry event

No response

SDK Setup

sentry.client.config.ts

import * as Sentry from '@sentry/nextjs'

const release =
  process.env.VERCEL_GITHUB_COMMIT_SHA ||
  process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA

console.log('Sentry.init with release:', release)

Sentry.init({
  release,
  dsn: 'xxx',
  tracesSampleRate: 1,
  debug: false,
  replaysOnErrorSampleRate: 1.0,
  replaysSessionSampleRate: 0.1,
  integrations: [
    Sentry.replayIntegration({
      maskAllText: false,
      blockAllMedia: false
    }),
    Sentry.captureConsoleIntegration(),
    Sentry.sessionTimingIntegration()
  ],
  enabled:
    process.env.NEXT_PUBLIC_VERCEL_ENV === 'production' ||
    process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'
})
\\\\

# ag sentry/
````bash
apps/dapp/src/app/global-error.tsx
3:import * as Sentry from '@sentry/nextjs'

apps/dapp/sentry.server.config.ts
1:import * as Sentry from '@sentry/nextjs'

apps/dapp/sentry.edge.config.ts
1:import * as Sentry from '@sentry/nextjs'

apps/dapp/sentry.client.config.ts
1:import * as Sentry from '@sentry/nextjs'

apps/dapp/package.json
21:    "@sentry/nextjs": "^7.114.0",

pnpm-lock.yaml
102:      '@sentry/nextjs':
2150:  '@sentry/browser@7.114.0':
2154:  '@sentry/cli@1.77.3':
2159:  '@sentry/core@7.114.0':
2163:  '@sentry/integrations@7.114.0':
2167:  '@sentry/nextjs@7.114.0':
2178:  '@sentry/node@7.114.0':
2182:  '@sentry/react@7.114.0':
2188:  '@sentry/replay@7.114.0':
2192:  '@sentry/types@7.114.0':
2196:  '@sentry/utils@7.114.0':
2200:  '@sentry/vercel-edge@7.114.0':
2204:  '@sentry/webpack-plugin@1.21.0':
9610:      '@sentry/core': 7.114.0
9611:      '@sentry/types': 7.114.0
9612:      '@sentry/utils': 7.114.0
9616:      '@sentry/core': 7.114.0
9617:      '@sentry/replay': 7.114.0
9618:      '@sentry/types': 7.114.0
9619:      '@sentry/utils': 7.114.0
9623:      '@sentry/core': 7.114.0
9624:      '@sentry/types': 7.114.0
9625:      '@sentry/utils': 7.114.0
9627:  '@sentry/browser@7.114.0':
9632:      '@sentry/core': 7.114.0
9633:      '@sentry/integrations': 7.114.0
9634:      '@sentry/replay': 7.114.0
9635:      '@sentry/types': 7.114.0
9636:      '@sentry/utils': 7.114.0
9638:  '@sentry/cli@1.77.3':
9650:  '@sentry/core@7.114.0':
9652:      '@sentry/types': 7.114.0
9653:      '@sentry/utils': 7.114.0
9655:  '@sentry/integrations@7.114.0':
9657:      '@sentry/core': 7.114.0
9658:      '@sentry/types': 7.114.0
9659:      '@sentry/utils': 7.114.0
9662:  '@sentry/nextjs@7.114.0(next@14.2.3)(react@18.3.1)(webpack@5.91.0)':
9665:      '@sentry/core': 7.114.0
9666:      '@sentry/integrations': 7.114.0
9667:      '@sentry/node': 7.114.0
9668:      '@sentry/react': 7.114.0(react@18.3.1)
9669:      '@sentry/types': 7.114.0
9670:      '@sentry/utils': 7.114.0
9671:      '@sentry/vercel-edge': 7.114.0
9672:      '@sentry/webpack-plugin': 1.21.0
9684:  '@sentry/node@7.114.0':
9687:      '@sentry/core': 7.114.0
9688:      '@sentry/integrations': 7.114.0
9689:      '@sentry/types': 7.114.0
9690:      '@sentry/utils': 7.114.0
9692:  '@sentry/react@7.114.0(react@18.3.1)':
9694:      '@sentry/browser': 7.114.0
9695:      '@sentry/core': 7.114.0
9696:      '@sentry/types': 7.114.0
9697:      '@sentry/utils': 7.114.0
9701:  '@sentry/replay@7.114.0':
9704:      '@sentry/core': 7.114.0
9705:      '@sentry/types': 7.114.0
9706:      '@sentry/utils': 7.114.0
9708:  '@sentry/types@7.114.0': {}
9710:  '@sentry/utils@7.114.0':
9712:      '@sentry/types': 7.114.0
9714:  '@sentry/vercel-edge@7.114.0':
9717:      '@sentry/core': 7.114.0
9718:      '@sentry/integrations': 7.114.0
9719:      '@sentry/types': 7.114.0
9720:      '@sentry/utils': 7.114.0
9722:  '@sentry/webpack-plugin@1.21.0':
9724:      '@sentry/cli': 1.77.3

apps/dapp/next.config.js
2:const { withSentryConfig } = require('@sentry/nextjs')
38:    // https://github.com/getsentry/sentry-webpack-plugin#options

Steps to Reproduce

  1. pnpm dev
  2. go to localhost:3000

Running:

  • pnpm 9.0.6
  • arch linux ( why not brag a bit 🤣 )
  • "@sentry/nextjs": "^7.114.0"
  • all my @sentry/utils at the same version ( see ag above )
  • have cleaned and redone all the node_modules, .next, .turbo, .swc

Expected Result

No console logs on the server side

Actual Result

Import trace for requested module:
./src/app/page.tsx

./src/app/page.tsx
Attempted import error: '_optionalChain' is not exported from '@sentry/utils' (imported as '_optionalChain').

Import trace for requested module:
./src/app/page.tsx

./src/app/page.tsx
Attempted import error: '_nullishCoalesce' is not exported from '@sentry/utils' (imported as '_nullishCoalesce').
@0x33dm 0x33dm changed the title Attempted import error _optionalChain and _nullishCoalesce on '@sentry/nextjs' 7.114.0 Attempted import error _optionalChain and _nullishCoalesce on @sentry/nextjs 7.114.0 May 9, 2024
@lforst
Copy link
Member

lforst commented May 10, 2024

arch btw 😂

would you mind checking your dependency lockfile for any versions of @sentry/* dependencies that may not be aligned? The only exception to this should be @sentry/webpack-plugin.

Otherwise, until we have figured this out, you could try migrating to the next major version 8.0.0-rc.2 of the SDK. That probably fixes it right away. Migration guide is here: https://docs.sentry.io/platforms/javascript/guides/nextjs/migration/v7-to-v8/

@0x33dm
Copy link
Author

0x33dm commented May 10, 2024

arch btw 😂

😂😂😂 💪

would you mind checking your dependency lockfile for any versions of @sentry/* dependencies that may not be aligned? The only exception to this should be @sentry/webpack-plugin.

I posted all the sentry lines on my lock file on my post?

Doesn't seem to be unaligned, but i will triple check!

Otherwise, until we have figured this out, you could try migrating to the next major version 8.0.0-rc.2 of the SDK. That probably fixes it right away. Migration guide is here: https://docs.sentry.io/platforms/javascript/guides/nextjs/migration/v7-to-v8/

Yes, will do that and get back to you. This is ideal

@lforst
Copy link
Member

lforst commented May 10, 2024

I posted all the sentry lines on my lock file on my post?

Ah I didn't scroll down in the code block. Sorry.

@0x33dm
Copy link
Author

0x33dm commented May 12, 2024

I posted all the sentry lines on my lock file on my post?

Ah I didn't scroll down in the code block. Sorry.

i run npx @sentry/migr8@latest and it did no changes to my code.

I'm currently running 7.114, I was expecting it to update my package.json to the latest 8.x release?

Since it didn't do it, I'm guessing I'm supposed to run the npm install for 8.x myself and then do all the other steps on the page you linked, is that assumption correct?

@lforst
Copy link
Member

lforst commented May 14, 2024

@sentry/migr8 unfortunately doesn't take care of everything for you. Especially @sentry/nextjs specific changes. If you do not have any special sentry code except for the basic setup you only have to follow the docs I shared! Generally when migr8 doesn't do any changes in your code it means that you don't have anything custom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants