-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
next build broken when wrapped with withSentryConfig #6782
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
Comments
Hi, |
@lforst I'm not sure I understand what you're suggesting. I've changed the module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions); I'm getting the same result. The issue seems to be occuring with next |
That should work. I did a test with next If that doesn't work, could you provide a small reproduction example so we can debug this further? Thanks! |
I deleted The output of the compilation seems to be there, other than the |
The SDK doesn't do anything to the |
Looks like I can't get When |
The release is out! Thank you! https://github.com/getsentry/sentry-javascript/releases/tag/7.31.1 |
@baraeb92 Can you share your next.js config? Thanks! |
We only include Sentry on production build at the moment. This works on v7.21.0 but not on the v.7.22.0 above, is there any breaking changes that we should be aware of? |
@iscekic @baraeb92 We'll probably release a new version on Monday that will resolve the issue for you. It's not really a fix but rather a revert of a change that broke a bunch of configurations that weren't dealing with the fact that You can read up on it in this PR: #6846 |
Thanks @lforst |
Thanks, I'm having the same issue as well! |
lol I'm glad Sentry noticed this. I had to do the following to handle this: module.exports = (phase, nextOptions) => {
const extended = extend(nextConfig).withPlugins(plugins);
const sentryExtendedNextConfig = sentry.extendNextConfig(extended(phase, nextOptions));
// sentry.extendNextConfig can return either an config object or a function. Because we're
// not sure which one it returns, we must check and handle each case.
if (typeof sentryExtendedNextConfig === "function") {
return sentryExtendedNextConfig(phase, nextOptions);
} else {
return sentryExtendedNextConfig;
}
}; |
Thanks @lforst |
We released a new version of the SDK. Let me know if it resolves your issue! |
I have the same problem and tested already the latest version 7.32.1. With 7.31.1 I hadn't that problem. Also running next 13.1.2. When try to build the next app with withSentryConfig(...) within the next.config.js I get this error: TypeError: withSentryConfig(...) is not a function My next.config.js: |
@kolorfilm It's not necessary to call the return value of |
When I handle the return value like, for example, @Sparragus mentioned, it works. Thanks, also @lforst for the clarification. |
@kolorfilm Glad you could get it resolved. This whole return value thing was a bit unfortunate (this PR description explains it a bit). Right now the function actually returns a function if you pass in a function and it returns an object if you pass in an object, we should adjust the type to reflect that. |
We need to pass the phase down, as it can't be added automatically. There was also upstream breakage with `withSentryConfig`, which caused problems, so forced an update to the lastest version. See: getsentry/sentry-javascript#6782
We need to pass the phase down, as it can't be added automatically. There was also upstream breakage with `withSentryConfig`, which caused problems, so forced an update to the lastest version. See: getsentry/sentry-javascript#6782
@lforst This is still broken for me, but I did manage to find the root cause, which is While I did get it to work, I prefer not using |
@iscekic Interesting. We have integration tests where we're not using swc and everything compiles fine. Can you provide a reproduction example? Thanks! |
We have been suffering this issue as well - we found the breakage happened after NextJS 13.1.1 - i.e. 13.1.2 and onwards cause this issue. The failure mode is really odd and took me a while to spot - here is the output from a failing Notice that it ends prematurely during source map upload and the builder comes back as DONE. It still has a lot more source maps to upload (all the client ones etc.) Same build, but with 13.1.1 instead of 13.1.2: The build continues after the source map upload. We confirmed (for us) that turning off source map uploads resolved the build issue for us:
Obviously this isn't ideal as although we can get a build through, we have no source map visibility in our releases currently. However, with the new information from @iscekic about Quick aside:
This is the really strange failure mode of this bug - |
I am also having this issue. I also do not want to use the swcMinifier. |
Okay so just testing with a test app of my own, Next.js 13 doesn't seem to like |
I could pinpoint this down to having This seems to be primarily an issue with Next.js so I will raise an upstream issue that hopefully gets resolved soon. In the meanwhile, I recommend using Edit: Here's the issue: vercel/next.js#45276 |
Okay it seems like this got upstream-fixed by vercel/next.js#45423 |
Would be good to update the nextjs documentation here: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#extend-nextjs-configuration |
@javierojgs What do you recommend we update it with? |
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 "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
Seeing this issue on Next.js v12.3.4 Any idea how to fix? |
@peterb0yd please open a new issue with details of the errors you're seeing and your setup. Thanks! |
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.30.0
Framework Version
nextjs 13.1.2
Link to Sentry event
N/A
SDK Setup
Steps to Reproduce
yarn next build
If
withSentryConfig
is removed, the build passes.Expected Result
Build succeeds,
next start
runs successfullyActual Result
The text was updated successfully, but these errors were encountered: