getsentry / sentry-javascript

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

7.17.x breaks builds with "... is not exported from ..." #6074

Closed fungilation closed 1 year ago

fungilation commented 1 year 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.17.1

Framework Version

React 17, Next 11

Link to Sentry event

No response

Steps to Reproduce

next build. Error ensues, ss from Vercel build

image

Expected Result

Build not breaking.

@sentry/nextjs 7.16.0 was fine.

Actual Result

Build breaks.

lforst commented 1 year ago

Hi, I tried to reproduce this with the newest version of the SDK but couldn't. Would you be able to provide a minimum reproduction example? Thank you!

Side-note: Even though it says "__sentrywrapped_\" in the logs, this is no indication of Sentry being the root of a problem - might not apply in this case but in general.

fungilation commented 1 year ago

I rolled back package.json to lock to ~7.16.0, and build is fine again. This is most definitely issue with sentry 7.17.x.

Here's my package.json:

{
  "private": true,
  "scripts": {
    "dev": "blitz dev",
    "build": "blitz build",
    "start": "blitz start",
    "lint": "eslint --ignore-path .gitignore --ignore-pattern '/test/*' --fix --ext .js,.ts,.tsx .",
    "test": "jest",
    "test:watch": "jest --watch",
    "typecheck": "tsc -p tsconfig.json --noEmit",
    "postinstall": "patch-package",
    "codegen": "DOTENV_CONFIG_PATH=.env.local graphql-codegen --require dotenv/config --config codegen.yml"
  },
  "dependencies": {
    "@apollo/client": "~3.6.9",
    "@coinbase/wallet-sdk": "^3.4.2",
    "@googlemaps/js-api-loader": "1.14.3",
    "@headlessui/react": "1.6.6",
    "@heroicons/react": "^1.0.5",
    "@hookform/resolvers": "~2.8.10",
    "@nhost/nextjs": "1.4.1",
    "@nhost/react": "0.9.1",
    "@nhost/react-apollo": "4.4.1",
    "@oauth-everything/passport-discord": "^1.0.2",
    "@paperxyz/react-client-sdk": "0.0.17",
    "@sentry/nextjs": "~7.16.0",
    "@stripe/react-stripe-js": "~1.7.0",
    "@stripe/stripe-js": "~1.29.0",
    "@walletconnect/web3-provider": "^1.8.0",
    "await-to-js": "3.0.0",
    "aws-sdk": "2.1105.0",
    "axios": "^0.25.0",
    "blitz": "0.45.3",
    "classnames": "^2.3.2",
    "coinbase-commerce-node": "1.0.4",
    "data-forge": "1.9.6",
    "data-forge-fs": "0.0.9",
    "dayjs": "^1.11.1",
    "ethers": "5.6.4",
    "exponential-backoff": "3.1.0",
    "graphql": "16.5.0",
    "graphql-request": "5.0.0",
    "lodash": "^4.17.21",
    "passport-steam": "^1.0.17",
    "passport-twitch-strategy": "^2.2.0",
    "passport-twitter": "fungilation/passport-twitter",
    "passport-youtube-v3": "^2.1.0",
    "raw-body": "2.5.1",
    "react": "^17.0.2",
    "react-coinbase-commerce": "1.6.0",
    "react-device-detect": "^2.2.2",
    "react-dom": "^17.0.2",
    "react-hook-form": "~7.25.3",
    "react-intersection-observer": "^9.4.0",
    "react-lite-youtube-embed": "~2.2.2",
    "react-lottie-tools": "^1.1.6",
    "react-scroll": "~1.8.7",
    "react-slick": "^0.28.1",
    "reactjs-popup": "2.0.5",
    "sass": "~1.49.11",
    "sha1": "1.1.1",
    "sharp": "^0.31.1",
    "slick-carousel": "^1.8.1",
    "steamapi": "2.2.0",
    "stripe": "10.15.0",
    "twitter-api-v2": "1.11.0",
    "uuid": "9.0.0",
    "web3": "1.7.5",
    "web3modal": "^1.9.8",
    "yup": "^0.32.11"
  },
  "devDependencies": {
    "@graphql-codegen/cli": "^2.12.1",
    "@graphql-codegen/introspection": "^2.1.1",
    "@graphql-codegen/typescript": "^2.8.0",
    "@graphql-codegen/typescript-graphql-request": "^4.5.5",
    "@graphql-codegen/typescript-operations": "^2.4.3",
    "@graphql-codegen/typescript-react-apollo": "^3.2.17",
    "@svgr/webpack": "6.2.1",
    "@types/google.maps": "3.50.4",
    "@types/js-cookie": "~3.0.2",
    "@types/node": "^18.8.5",
    "@types/passport-steam": "^1.0.1",
    "@types/passport-twitter": "^1.0.37",
    "@types/react": "17.0.47",
    "@types/react-scroll": "~1.8.4",
    "@types/react-slick": "^0.23.10",
    "@types/uuid": "~8.3.4",
    "autoprefixer": "^10.4.12",
    "crypto-browserify": "^3.12.0",
    "eslint": "^8.26.0",
    "eslint-config-next": "12.2.5",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.2.1",
    "https-browserify": "^1.0.0",
    "os-browserify": "^0.3.0",
    "patch-package": "6.5.0",
    "postcss": "^8.4.18",
    "postinstall-postinstall": "2.1.0",
    "prettier": "^2.7.1",
    "stream-http": "^3.2.0",
    "tailwindcss": "~3.0.24",
    "typescript": "~4.5.5",
    "url": "^0.11.0"
  }
}
bas080 commented 1 year ago

I think my stack trace is related to this issue as reverting my nextjs version back fixes things also. The stack trace is as follow:

warn  - Detected getInitialProps on page '/_error' while running "next export". It's recommended to use getStaticProps which has a more correct behavior for static exporting.
Read more: https://nextjs.org/docs/messages/get-initial-props-export

Error occurred prerendering page "/404.html". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: Cannot read properties of undefined (reading '__sentry_original__')
    at Object.autoEndTransactionOnResponseEnd (/home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/utils/responseEnd.js:34:19)
    at /home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:92:19
    at bound (node:domain:433:15)
    at runBound (node:domain:444:12)
    at Object.callTracedServerSideDataFetcher (/home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/wrapperUtils.js:128:5)
    at Function.getInitialProps (/home/ant/projects/localu/node_modules/@sentry/nextjs/cjs/config/wrappers/withSentryServerSideErrorGetInitialProps.js:38:23)
    at /home/ant/projects/localu/node_modules/next/dist/shared/lib/utils.js:84:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/home/ant/projects/localu/node_modules/@swc/helpers/lib/_async_to_generator.js:23:28)
    at _next (/home/ant/projects/localu/node_modules/@swc/helpers/lib/_async_to_generator.js:12:17)
info  - Exporting (4/4)
Error: Export encountered errors on following paths:
    /_error: /404
    /_error: /404.html
    at /home/ant/projects/localu/node_modules/next/dist/export/index.js:405:19
    at async Span.traceAsyncFn (/home/ant/projects/localu/node_modules/next/dist/trace/trace.js:79:20)

I believe it's related to the req not defined issue which I thought was merged but have not checked if it's released already.

Some information that might be related: I have also updated nextjs to 13

lforst commented 1 year ago

@bas080 this is very likely unrelated to this issue

lforst commented 1 year ago

This is most definitely issue with sentry 7.17.x.

@fungilation This would surprise me since we didn't introduce any changes between 7.16.0 and 7.17.x that would likely result in the error you're describing. Can you double-check whether the issue persists with 7.17.2?

bamtheboozle commented 1 year ago

on 7.17.x i get this on a very minimal nextjs app

 Using `export * from '...'` in a page is disallowed. Please use `export { default } from '...'` instead.
  | Read more: https://nextjs.org/docs/messages/export-all-in-page
   ,----
 2 | export * from './_app.tsx?__sentry_wrapped__';

this does not happen on 7.16.0, and i don't have any export * in the app

lforst commented 1 year ago

on 7.17.x i get this on a very minimal nextjs app

 Using `export * from '...'` in a page is disallowed. Please use `export { default } from '...'` instead.
  | Read more: https://nextjs.org/docs/messages/export-all-in-page
   ,----
 2 | export * from './_app.tsx?__sentry_wrapped__';

this does not happen on 7.16.0, and i don't have any export * in the app

@bamtheboozle Are these logs from building locally or on Vercel? If it is local, do you happen to be running Windows?

bamtheboozle commented 1 year ago

locally on windows, you are right

lforst commented 1 year ago

@bamtheboozle I think your problem is related to https://github.com/getsentry/sentry-javascript/issues/6085 and unrelated to this issue.

fungilation commented 1 year ago

I tried upgrading to 7.17.3. No dice, see Vercel build error log: Deployment Overview – Dashboard – Vercel.pdf

What's interesting however is on local (macOS 12.6), I can next build without error. So issue is specifically with Vercel's build env, and specifically something with 7.17.x. As I confirm again that reverting my sentry dep to 7.16.0 and Vercel build succeeds again without issue.

github-actions[bot] commented 1 year ago

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 🥀

fungilation commented 1 year ago

Here's a comment, bot

lforst commented 1 year ago

Can you try upgrading to 7.20.1? Please keep in mind that the latest version of the SDK (7.21.0) has a bug that we aim to fix in 7.21.1 and currently won't work.

lforst commented 1 year ago

Looking into this again, I think this might be an issue with blitz.

fungilation commented 1 year ago

Tried both 7.17.4 and 7.20.1. Same Vercel build errors as in my 1st comment above

pawlarius commented 1 year ago

Not sure if this will help the team to debug, but I got the same error message about __sentry_wrapped__ with Vercel NextJS v12.0.7 with library @sentry/browser & @sentry/nextjs. I tried changing both library version to 7.0.0, 7.10.0, 7.25.0, 7.26.0 with no avail.

But when I upgrade the sentry version in another NextJS project with v11.1.2, both of the sentry library at v7.26.0 is working fine and can be built by Vercel normally.

That got me thinking, seems like some version of NextJS is not working well with Sentry. So I upgraded my first project NextJS version from 12.0.7 to 12.1.0 and now it's all working fine!

fungilation commented 1 year ago

Interesting. Too bad I have a Blitz.js dependency and its forked version of Next, or I'd have upgraded Next.

github-actions[bot] commented 1 year ago

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 🥀

fungilation commented 1 year ago

Shoo shoo, bot

lforst commented 1 year ago

Hi, we need a reproduction to debug this further. Seems like not many people are running into this. I also recommend raising an issue in the Blitz.js project. Maybe they can bump the Next.js version.

github-actions[bot] commented 1 year ago

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 🥀