-
Notifications
You must be signed in to change notification settings - Fork 0
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
"Out of Memory" ("OOM") event during next build (Vercel) #19
Comments
Assigning to /support for routing ⏲️ |
hi , could you share your |
Click the checkbox below to generate a PR!
@hiroshinishio, You have 3 requests left in this cycle which refreshes on 2024-11-05 22:45:17+00:00. |
Click the checkbox below to generate a PR!
@hiroshinishio, You have 2 requests left in this cycle which refreshes on 2024-11-04 02:56:25+00:00. |
Can confirm. Ours has been doing that as well. Currently playing with different options to see which one will work.
|
Seems like |
Thanks for reporting !
Can you share your Next.js version, webpack version, and sentry sdk version? We need this to try and reproduce this issue.
How much big is your server-side codebase? This stops sourcemaps generation + uploading for your server-side code, which means you get way worse stacktraces potenially. If you set |
Not sure about webpack but it seems like peer dependency of |
This causes OOM. |
you can run
looks like this is a next.js + Vercel issue then. If you can get the exact next version via Just to ask again, how much big is your server-side codebase? Number of API routes, avg lines of code? This might help explain why OOM is happening (helps build better reproduction for Vercel folks as well). thanks a lot of helping us debug!! |
The majority ouf our code are using server actions.
|
I have a similar issue the OOM starts when i bump next from But in my case the when i try to add: webpack: (config, { isServer }) => {
if (isServer) {
config.devtool = 'source-map'
}
return config
}, No OOM happens. If can help: nextConfig,
{
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options
// Suppresses source map uploading logs during build
silent: true,
org: '..',
project: '..',
},
{
// disableServerWebpackPlugin: true,
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: false,
// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
// TODO: Use tunneling when is resolved
// https://github.com/getsentry/sentry-javascript/issues/8293
// tunnelRoute: "/web/monitoring",
// Hides source maps from generated client bundles
hideSourceMaps: true,
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
} Also setting |
This actually helps a lot in narrowing down the problem. Thank you very much! That particular Next.js release includes a PR that sounds like it could cause excessive memory consumption when generating source maps for the server. I have contacted vercel and we are trying to figure this out. If you could provide a reproduction example inside a repository that we can clone, that would be awesome! |
We're starting to see OOM issues on Vercel as well. It mostly started when we started migrating some pages to Next.js App Dir router. |
this is impacting our customer and blocking a next.js migration. thanks for looking into this issue. |
Really glad to have stumbled upon this issue, I've been pulling my hair out trying to figure out the cause of our OOM issues. We're on Does anyone have a set of versions that fixes this issue by chance? Removing Thank you! |
As mentioned above, the workaround is to set // next.config.(js|mjs)
const nextConfig = {
sentry: {
disableServerWebpackPlugin: true,
},
}; This is because the memory issues come from a combo of Next.js + Vercel itself, specifically about generating server-side sourcemaps - the Sentry SDK itself has no control over this, but we require sourcemaps to be generated so we can upload them. Do note, setting |
That did work, thanks. Hopefully we can re-enable that soon. |
any update here ? :) curious if this has been resolved given the vercel / nextjs ticket you linked (vercel/next.js#59569) says it's merged. Is there a more recent ticket I should look at on their end? |
No update from our side. I'll ping Vercel about whether this issue has been fixed. It's best for you to just try things out on the newest Next.js version. The PR I linked was the culprit, not the fix. |
Checking if there is any update on this? Adding Sentry to our nextjs app is increasing the build time from 4 min to 20+ minutes! I've removed replay, adding tree shaking in the webpack config, and tried adding Here is my next.config.js
|
do you see these build slowdowns in local development as well?
If you only see this issue in Vercel build, and the issue still persists when you set the |
is there any workaround you might suggest for how we can upload source maps manually? |
you can upload source maps manually by following this guide: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/ I think the memory consumption + long build time comes from the fact that source maps are generated. Source maps generation takes up a lot of memory in webpack. It should not be the uploading part that is expensive. |
Hey! I’m encountering a similar issue when uploading sourcemaps for my Next.js project to Sentry during the build process on CircleCI. This issue started after migrating our first page to the App Router architecture. The build hangs specifically when uploading the client sourcemap. The logs show:
It’s worth noting that without the App Router, the build works without any issues. Also, disabling sourcemaps upload allows the build to complete successfully. Here’s the configuration we’re using in withSentryConfig: withSentryConfig(nextConfig, {
silent: true,
disableLogger: true,
sourcemaps: {
disable: process.env.DISABLE_NEXT_SENTRY_SOURCEMAP_UPLOAD === 'true',
deleteSourcemapsAfterUpload: true,
},
}) Could manually uploading the sourcemaps be a viable workaround for this issue? If so, could you provide guidance or an example on how to upload all sourcemaps (edge, server, and client) for a Next.js project? Thanks! |
Hi, building source maps is unfortunately relatively memory intensive. We don't do anything funky in the SDK besides turning on source map generation. You might want to raise this with the Next.js team, ideally by also sharing a memory profile of the build. |
Thank you for the quick response and the valuable insights! I didn’t initially realize that increasing the Node.js memory limit with the Thanks again for your help! |
We tried to update from 7.99.0 to 8.25.0 and our github actions started failing (cancelled automatically after 30min+). Disabling sourcemaps with sourcemaps: {
disable: true,
deleteSourcemapsAfterUpload: true,
}, does fix the builds, but we had sourcemaps just fine on 7.99.0 |
Please try to provide a memory profile for when this happens. |
I'm back with slightly more pieces of info: a) When failing, here is the error reported by github:
b) I've added catchpoint/workflow-telemetry-action, and a successful (with sourcemaps disabled c) We build 7 next.js applications at the same time. d) Here is build config used in all seven apps: const sentryConfig = {
widenClientFileUpload: true,
tunnelRoute: "/monitoring",
hideSourceMaps: true,
disableLogger: true,
silent: true,
sourcemaps: {
deleteSourcemapsAfterUpload: true
},
release: {
name: process.env.NEXT_PUBLIC_CI_COMMIT_SHORT_SHA ?? "Dev"
},
authToken: process.env.SENTRY_TOKEN,
org: "org",
project: "project"
}; e) I've attempted to give the failing job some time and then to cancel it (cancelled jobs still produce memory chart). The original no-cancel ran spanned 40 minutes, so I tried cancelling it 20 minutes after start, 10 minutes after start and 5 minutes after start. In 20-minute and 10-minute runs died with
The 5-minute run produced this chart f) For cancelled/failed jobs, raw github logs end with
(meaning basically nothing gets logged) g) sentry v7.99.0 with sourcemaps enabled gives this chart h) sentry v7.99.0 with sourcemaps disabled ( i) These charts are not very enlightening, but we don't self-host builds, so I'm not sure how to capture anything more useful |
We'll continue to look into this next week as this week is Hackweek at Sentry (getsentry#13421) |
we're seeing a similar thing on our builds disabling sourcemaps has resolved this for now |
Same issue for us in a standard // next.config.js
module.exports = withSentryConfig(module.exports, {
sourcemaps: {
disable: true,
},
} |
What made it work for us was updating package.json - i.e., the
We did NOT disable sourcemaps. |
for us even with the max 8GB (on non enterprise plan) vercel gives you for build containers, we were always OOMing at this point with sourcemaps turned on |
Hey everyone, for now the best workaround still is to increase Other than that,
still holds up. Looking at the provided screenshots of memory consumption from I don't see the SDK doing anything crazy in terms of memory consumption but rather slightly increasing already very high consumption. |
Here, its not work with disable source maps. (no versel - we use Kaniko to build/deploy the image). and... not work incrase "NODE_OPTIONS="--max-old-space-size=4096" |
It would be cool if you could provide a memory profile. Thanks! |
idk how to provide a memory profile from kaniko! Sorry i dont have permissions to do that! But i run local on my dockerfile and get this results with next build --experimental-debug-memory-usage Look how many memory uses incrase!! Without Sentry:
With Sentry:
|
Can you try disabling Sentry but enabling high-quality (!) source map generation, to see how much Sentry contributes to those stats? Thanks! |
Do you have a link or something that would tell me how to emable high-quality source maps? The closest I found is https://nextjs.org/docs/app/api-reference/next-config-js/productionBrowserSourceMaps |
You can do this in your next.config.js:
|
I've done
|
thanks for doing the research! To me the table indicates that the increased memory consumption is indeed related to source maps being turned on, and not the SDK being added per se? Or would you interpret it differently? |
I cannot speak from any experience as this was the first time I used |
I've decided to do two more runs with same debug flags:
Damn I might have forgot to enable debug in sentry v7 Btw, node version is |
Thanks again for doing the research. From looking at this data, and also data that other folks provided it seems to me that the additional memory consumption is not excessive but we are hitting an unfortunate threshold that seems to be pushing it for various build pipelines. I cannot think of a fix for this right now, except for disabling sourcemaps, but that will massively degrade your experience when using Sentry for error monitoring. Alternatively, try to increase your memory limit. As far as I am aware, and from when I talked to them last, Vercel does already know that sourcemaps consume too much memory and are looking for ways to improve this. From our end we can just hope that things improve upstream, or when there doesn't seem to be any movement we can contribute too. |
Our team is running into this same issue, had to disable sourcemaps which is obviously not ideal in terms of Sentry experience. Tried reducing our dependencies(removing unused/duplicates) to free up some memory, but 90% of our builds are still failing due to memory constraints. Exploring using turbo cache atm so we don't have to build on Vercel, we'll see if that helps resolve the issues 🤞 But ideally Sentry/Vercel would somehow resolve this. |
We cannot resolve this from our end. Please raise this with the Next.js team! |
Sorry, we have an error. Please try again. Have feedback or need help? |
Environment
SaaS (https://sentry.io/)
What are you trying to accomplish?
I'm trying to build my Next.js project
How are you getting stuck?
The build fails with "Out of Memory" ("OOM") event if sentry is enabled. If I remove sentry from my code, the next build works.
Where in the product are you?
Bug Report
Link
No response
DSN
No response
Version
No response
The text was updated successfully, but these errors were encountered: