-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
JavaScript heap out of memory #12594
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 @foodiecompany could you share your The issue here is probably sourcemaps generation (which is handled by nextjs, sentry just is responsible for uploading). What version of next.js/webpack are you using? |
Sure const { withSentryConfig } = require("@sentry/nextjs");
const path = require("path");
const env = process.env;
const SENTRY_PROJECT_NAME = env.SENTRY_PROJECT_NAME;
const IS_PRODUCTION = env.NODE_ENV === "production";
const STRAPI_MEDIA_HOST = IS_PRODUCTION ? "res.cloudinary.com" : "127.0.0.1";
let config = {
reactStrictMode: true,
output: "standalone",
transpilePackages: [
"ui",
"@ant-design",
"antd",
"rc-pagination",
"rc-picker",
"rc-util"
],
images: {
remotePatterns: [
{
protocol: IS_PRODUCTION ? "https" : "http",
hostname: STRAPI_MEDIA_HOST
}
]
},
experimental: {
outputFileTracingRoot: path.join(__dirname, "../../"),
optimizePackageImports: ["lodash", "@ant-design", "antd"],
// The instrumentation hook is required for Sentry to work on the serverside
instrumentationHook: true
}
};
// Injected content via Sentry wizard below
if (SENTRY_PROJECT_NAME) {
config = withSentryConfig(config, {
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options
org: "fastybill-vr",
project: SENTRY_PROJECT_NAME,
// Only print logs for uploading source maps in CI
silent: true,
// 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: true,
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: "/monitoring",
// Hides source maps from generated client bundles
hideSourceMaps: true,
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
// Enables automatic instrumentation of Vercel Cron Monitors.
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true
});
}
module.exports = config;
Dockerfile
|
Can you try this workaround? #10468 (comment) |
works thx
|
I'm seeing similar issues in version 8.11.0, specifically when building within a docker container. This version doesn't have the same disableServerWebpackPlugin and disableClientWebpackPlugin options but I've tried with: unstable_sentryWebpackPluginOptions: {
disable: true
} which doesn't seem to help. Builds without the withSentryConfig wrapper work fine. |
This is very likely because webpack is consuming a lot of memory generating sourcemaps. You can set the following in version module.exports = withSentryConfig(nextConfig, {
sourcemaps: {
disable: true
}
}) |
On @sentry/nextjs 8.26.0 , Next.js 14.2.5 , and adding sourcemaps: { disable: true } still getting heap memory error.
|
@pascuflow exporting your next.js config without Sentry does not cause any errors? Can you share your |
Don't think I can control NODE_OPTIONS on Vercel. |
Pretty sure you can provide the env var in the interface you configure the build script with 🤔 |
You're right, directly in the build script worked.
|
@pascuflow did it actually resolve your issue? |
Yes, build was successful with repo on Github and Vercel deployment. Logged an error in production and saw it on the Issues tab along with source mapping. |
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 remove the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
I'm still seeing this issue using the Vite plugin, disabling the sourcemaps fixes it but that isn't ideal for anyone using Sentry to help debug things ☹ |
@mikehuebner you can try adding |
We have it set to 10gb, so it isn't that. Excluding node modules fixed it! |
I'm getting this issue even using NODE_OPTIONS="--max-old-space-size=8192" on a 8GB build server. I've also tried playing around with the number to try to get it to work, but nothing does.
@mikehuebner Sorry what exactly do you mean excluding node modules? |
I can reference it tomorrow, but there was a comment that shows how to exclude node modules from your source maps! Edit: if it's still happening with your source maps disabled, I can't help you there 🥲 |
@mikehuebner A reference would be incredibly helpful! A few googles searches + checking related sentry github issues for what you're talking about has left me empty handed. Please share whenever you have the time! |
If you have this set to
From the docs -
|
Uh oh!
There was an error while loading. Please reload this page.
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.117.0
Framework Version
@sentry/nextjs
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
npm run build
Expected Result
Actual Result
The build is successful when Sentry is disabled.
The text was updated successfully, but these errors were encountered: