Closed moonmeister closed 5 years ago
Okay, so this is definitely a node issue. It seems that the extra transpiling being done is just now making node hit it's default limit in my case. I ran export NODE_OPTIONS=--max_old_space_size=4096
to expand the defaults and build is now happy.
this seems strange that node doesn't just request more memory if it's available, also I'm a little concerned how this might affect folks build servers.
Yeah, affects Netlify too. I was able to get Netlify to build correctly by adding an environment variable:
[build.environment]
NODE_OPTIONS = "--max_old_space_size=4096"
This seems like it might negatively affect a lot of people. Any way we can make this more memory efficient?
@moonmeister OMG thank you so much I just updated my package.json file and suddenly this issue crept up. And yes increasing the size solved the issue.
@vickylance figured I wouldn't be the only one. Glad you figured it out.
However netlify does not seem to build even after increasing the node size. Its not throwing an error but its just staying building forever.
EDIT: it got published. But it took a lot of time to build
I've got the same issue I think, @vickylance and @moonmeister - I can test the environment variable fix if someone can guide me how? :) Not done them before - is it just as here in Netlify?
Not sure you need the quotes but that looks correct.
OK - didn't work with the quotes initially. I'll try without.
EDIT: Works without quotes in Netlify
Yeah, build times have definitely increased. I'm not sure what value this adds, I'm sure it does but it seems to have some significant downsides too.
Add in netlify like this.
@moonmeister Yes my build time was less than a min and now its more than 6 mins
Same here; environment variable fixed it, but it took an age to deploy.
Not sure about you guys but I also got a lot of lines of...
10:04:46 PM: Pkg: FLAGS_MISMATCH
Not seen that before myself.
EDIT: In Netlify EDIT 2: Gone from 4 mins to 7 mins.
@gatsbyjs/core Can we get some input here? This isn't strictly a Gatsby issue but definitely caused by a decision the Gatsby project made. IS there a way to disable this for folks that don't want it, or maybe a way to optimize the process to increase performance/build times (or at least not break node)?
It only took 20-40s longer on gatsbyjs.org when transpiling node_modules so it's weird that it's so heavy for your sites. I'll have a look at your repro! @moonmeister
@wardpeet Thanks! My site is only page (aside from the cms), so it wasn't much to start with...but it probably still doubled.
If anyone else has repositories they can share that may be helpful.
Same problem on my side. This has been driving me bananas. I'm glad to find out it's an issue on Gatsby's last version
Seems like gatsby-netlify-cms being the issue. I'll cook up a fix.
Sorry for the inconveniences
https://github.com/gatsbyjs/gatsby/pull/15191 seems to be ready to get merged!
@wardpeet can you explain why this plugin specifically is an issue? Is it purely its size?
gatsby-plugin-netlify-cms
runs an independent Webpack build within Gatsby's Webpack build (insert "yo dawg" reference here) using a modified version of the Gatsby Webpack config. Gatsby 2.11.0 no longer excludes node_modules
, which causes the plugin's Webpack build to attempt processing the Netlify CMS modules with Babel. The modules are massive and also prebuilt, so it will (and should) crash your system.
The PR I raised just adds that exclusion back in to the plugin's Webpack config. Please don't override your node max file size limit to fix this!
Hi all, this had us stumped for a minute.
Thanks, @moonmeister for posting a temporary fix.
Yes, it increased our build time quite a bit too but at least it is building again.
@erquhart - are you suggesting we shouldn't use the temp fix?
Sorry, no - definitely good as a temp fix, just recommending folks revert back once a proper fix is released.
Will #15191 be sufficient for a developer who uses gatsby-plugin-netlify-cms & uses Yarn's PnP feature?
I also experienced the same thing, high memory usage on gatsby build.
after investigated a little further, i think this block of code from https://github.com/gatsbyjs/gatsby/pull/14111/commits/4210885b605f61d49fec786509441bb28dc0570e commit that caused the problem:
let js = ({ exclude = [], ...options } = {}) => {
const excludeRegex = [
`core-js|event-source-polyfill|webpack-hot-middleware/client`,
].concat(exclude)
return {
test: /\.(js|mjs|jsx)$/,
exclude: new RegExp(excludeRegex.join(`|`)),
type: `javascript/auto`,
use: [loaders.js(options)],
}
I succesfully running gatsby build after revert webpack-utils.js
back to this https://github.com/gatsbyjs/gatsby/pull/14111/commits/d46f17b8fe7a9eb566f257b0c8174ae273660875 commit
{
let js = (options = {}) => {
return {
test: /\.(js|mjs|jsx)$/,
exclude: /core-js|event-source-polyfill|webpack-hot-middleware\/client/,
type: `javascript/auto`,
use: [loaders.js(options)],
}
}
rules.js = js
}
I suspect the RegExp
causing this memory inefficiency
@hendra-go is the project you're seeing this issue in using the Netlify CMS plug-in?
Sent with GitHawk
@hendra-go is the project you're seeing this issue in using the Netlify CMS plug-in?
@erquhart No, i dont use Netlify CMS plug-in, i try to build locally, using gatsby@2.11.0
even using node --max-old-space-size=4096
when running gatsby build did not work on my laptop with 8GB memory.
Interesting, maybe Gatsby itself is having the same issues the Netlify CMS plug-in build is having. It's likely due to the commit you mentioned (from #14111), but I don't think it's a RegExp perf issue - seems more probable that it's due to Babel now processing modules that used to be excluded, especially in node_modules
. I could easily be wrong though, @wardpeet should have more insight.
Sent with GitHawk
I am too experiencing this problem with Gatsby 2.11.x versions and not with 2.10. I downgraded for now.
Also getting this issue with Gatsby 2.11.x while using styled-components. Sticking with 2.10 for now.
I have the same issue. A downgrade to 2.10 solved the problem
@hendra-go mind sharing your repo?
new version of gatsby-netlify-cms got published 4.1.1, it should fix this issue.
It seems fixed for me. Thanks!
Still broken for me when using styled-components
🤔
I ran into this today as well:
[BABEL] Note: The code generator has deoptimised the styling of undefined
as it exceeds the max of 500KB.
It happens for a large markdown file (exactly this long read blog post which I want to transfer from my old Hugo website to my new Gatsby website). In Gatsby I use PrismJS and MDX. The 1600th line of markdown kills it.
So I am not entirely sure whether it is related, because I am not using Netlify. If not related, I am happy to open a new issue.
My dependencies:
"dependencies": {
"@mdx-js/mdx": "^1.0.21",
"@mdx-js/react": "^1.0.21",
"axios": "^0.19.0",
"disqus-react": "^1.0.6",
"dotenv": "^7.0.0",
"gatsby": "^2.12.0",
"gatsby-image": "^2.2.3",
"gatsby-link": "^2.2.0",
"gatsby-mdx": "^0.6.3",
"gatsby-plugin-catch-links": "^2.1.0",
"gatsby-plugin-feed": "^2.3.1",
"gatsby-plugin-google-analytics": "^2.1.1",
"gatsby-plugin-manifest": "^2.2.0",
"gatsby-plugin-offline": "^2.2.0",
"gatsby-plugin-react-helmet": "^3.1.0",
"gatsby-plugin-sentry": "^1.0.1",
"gatsby-plugin-sharp": "^2.2.1",
"gatsby-plugin-sitemap": "^2.2.1",
"gatsby-plugin-styled-components": "^3.1.0",
"gatsby-remark-autolink-headers": "^2.1.0",
"gatsby-remark-copy-linked-files": "^2.1.0",
"gatsby-remark-images": "^3.1.2",
"gatsby-remark-prismjs": "^3.3.0",
"gatsby-source-filesystem": "^2.1.1",
"gatsby-transformer-remark": "^2.5.0",
"gatsby-transformer-sharp": "^2.2.0",
"prismjs": "^1.16.0",
"react": "next",
"react-dom": "next",
"react-facebook-pixel": "^0.1.1",
"react-helmet": "~5.2.1",
"react-quora-pixel": "0.0.5",
"react-twitter-conversion-tracker": "^1.0.0",
"react-youtube": "^7.9.0",
"styled-components": "^4.3.2"
},
Before I had Gatsby 2.3.25 and ran into the same issue (in case we want to exclude a regression bug). Then I updated full of hope that a new version would resolve it.
Gatsby 2.12.x seemed to of fixed all of my issues
I am following the Gatsby tutorial from https://www.netlifycms.org/docs/gatsby/
I am running Gatsby 2.13.2, build on Netlify crashed but the fix NODE_OPTIONS = "--max_old_space_size=4096"
did the job.
@wernerglinka netlify-cms changed the name of it's package to netlify-cms-app. That may be affecting you, not sure.
Having same issue here.
This was fixed - are you sure it's the same exact issue? Also make sure you have the latest version of both Gatsby and the Netlify CMS Gatsby plugin.
Sent with GitHawk
Thanks Alex, I updated to netlify-cms-app and everything works. Werner
Sent from my iPad
On Jul 4, 2019, at 19:20, Alex Moon notifications@github.com wrote:
@wernerglinka netlify-cms changed the name of it's package to netlify-cms-app. That may be affecting you, not sure.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
I added the environment variable --max-old-space-size=4096 to netlify and managed a successful build. I deleted lock files deleted node_modules and re-installed. Same issue as far as I can `see.
"dependencies": {
"gatsby": "^2.13.4",
"gatsby-plugin-netlify-cms": "^4.1.1",
"netlify-cms-app": "^2.9.5",
"react": "^16.8.6",
"react-dom": "^16.8.6"
}
In case it helps figure any of this out, this repo that uses Netlify CMS appears to still be broken under 2.13.6 2.13.9, but everything is fine under 2.10.5. See master branch vs https://github.com/rdela/voidcluster/pull/54; build failure log at https://app.netlify.com/sites/voidcluster/deploys/5d20f59e9f191b000a971e08
https://app.netlify.com/sites/voidcluster/deploys/5d242cc7332e50bd7113ca72
@erquhart I commented on your PR already on Jul 6, 2019 at 12:40 PM PDT, a few hours after your last post here: https://github.com/gatsbyjs/gatsby/pull/15191#issuecomment-508949236 ...not sure whether you got notified already or not, if so, sorry for the double mention and thanks for all the work trying to resolve this!
Yeah, affects Netlify too. I was able to get Netlify to build correctly by adding an environment variable:
[build.environment] NODE_OPTIONS = "--max_old_space_size=4096"
This worked for me <3
Added "(JavaScript heap out of memory)" to end of issue title just now (in addition to reopening yesterday) to try and prevent more duplicate issues like #15540
I'll be closing this one in favor of #15256
Please move the discussion to that thread. I have created a PR that hopefully fixes the OOM issue https://github.com/gatsbyjs/gatsby/pull/15588
#15588 #15591 has done the trick for me thanks @wardpeet!
I just got hit with this. Gatsby version 2.13.31, Node 10.15.3 via npx and npm 6.4.1
I had imported a file that was 8mb, which was working just a few days ago. @moonmeister 's solution worked for me - increase memory with export NODE_OPTIONS=--max_old_space_size=4096
Description
Gatsby 2.11 breaks site build. I'm guessing it's the new functionality around building node_modules as well as the site (#14111).
i was updating dependencies on master when build started breaking. I've updated to 2.10.5 on an update branch with no troubles but as soon as I move Gatsby to 2.11 the build breaks.
Steps to reproduce
Expected result
build should be successful.
Actual result
Environment