-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
nuxt generate memory leak #7855
Comments
I discovered this only happens on the first run (but reliably on the first fresh run), if after the crash due to out of memory I run the same generate command again, heap usage hovers around 500MB and stays there throughout each generated route. So my weird workaround is to let it crash and run again. |
Hi @andrewharvey. Do you have a reproduction repo or if hard possibily privately sharing repo? |
I'll try to cut it down into something reproducible, but for a large application this isn't straightforward. I tried running an allocation timeline profile, but because of the resources required just to capture it I could only capture a few seconds, and to be honest I can't really understand it |
Same problem! Nuxt generates 1/5 pages, freezes, eats up all memory and crashes. Last normally working version for me 2.12+ |
I also encountered this problem while first upgrading to Nuxt 2.13 (Javascript heap out of memory while generating pages). For me, this happened for 2 reasons:
|
I'm running into this issue as well. My repository is public: https://github.com/AliasIO/wappalyzer.com
|
Hi, you could try disabling the export default {
generate: {
crawler: false
}
} |
@Atinux That fixes it, no issue on 2.14 with |
@Atinux Unfortunately nothing has changed UPD: After all, there was an error in my code... In my case, the problem arose because in one of the components, the name of the nested component and the name of the exported class coincided. import { Component, Vue } from 'nuxt-property-decorator';
@Component({
components: {
Blablabla: () => import('@/components/Blablabla.vue'), // Here
},
})
export default class Blablabla extends Vue {} // And here 😁 I have no idea why it worked normally in on Nuxt 2.12+. Maybe it'll help somebody. |
@Atinux I thought disabling the crawler fixed it but I'm having the same issue again. I downgraded to 2.12 for now. |
Having the same issue when i upgraded from 2.13 to 2.14, fails at It seems to work for fully static if i cancel and run the command again (2 tries to work every time), but without full static (original legacy static) it doesn't seem to work and hangs. Not sure if related but #5546, Downgraded to 2.13 for now |
I just spent a whole day trying to optimize what I thought was a leaky application. I'm increasingly certain that the problem lies with Nuxt, especially hearing I'm not the only one. Over the course of debugging memory consumption, I can see that even after the generate process has completed, our generate process leaves over 2GB sitting in heap. Our application is fetching fairly large payloads in the fetch method, across most routes of a fairly large site (many hundreds of routes). If I limit the amount of data that is being fetched here, the problem is less noticeable. Thus the problem seems to scale both with the amount of data being fetched and the number of routes being generated. |
@pi0 I spent a few hours reducing my project to a minimally reproducing example. https://github.com/andrewharvey/nuxt-bug-7855 Running There are still a few pieces but I've hit the point where if I take something out I don't see the issue anymore, so it's hard to work out what exactly is causing it. UPDATE: though if I replace https://github.com/andrewharvey/nuxt-bug-7855/blob/master/store/index.js#L15 with the similar bit from earlier in the file then looks like the issue goes away... |
Thanks for your contribution to Nuxt.js!
Issues that are labeled as |
@Stale I updated https://github.com/andrewharvey/nuxt-bug-7855 to use nuxt-edge and it's still reproducing as per #7855 (comment) |
Thanks for your contribution to Nuxt.js!
Issues that are labeled as |
@Stale Yes I can still replicate, updated nuxt-edge to latest. However the workaround does seem to make a difference, so that might be helpful for anyone interested in looking at this. |
Sorry for the delay, I have this issue in my todo list since it could affect also Nuxt 3. |
I'm looking into this and will update this comment with my current thinking, which undoubtedly will change. I can replicate this issue using the repo above - with the CLI - as long as there is an initial build (you can also force this on subsequent builds by setting const { Builder, Generator, Nuxt } = require('nuxt-edge')
const config = require('./nuxt.config.js')
async function main() {
const nuxt = new Nuxt({
...config,
dev: false
})
await nuxt.ready()
const builder = new Builder(nuxt)
const generator = new Generator(nuxt, builder)
await generator.generate()
}
main() |
@andrewharvey To add to the above, as far as I can tell the specific memory leak you've identified is caused by Vuetify rather than Nuxt (cc: @kevinmarrec). I haven't been able to confirm that in your case @AliasIO - if you can get in contact with an API key so I can generate routes locally for your site I'd be grateful. If anyone in this thread who has encountered a memory leak like this and is not using Vuetify I'd welcome a reproduction or more information. |
I have recently experienced the same problem in a corporate environment, I have tried using several new installations of the same version of ubuntu (20.04, 18.04), nodejs (v12, v14) and even docker, The difference I can think of but can't test is, Sorry I'm not a front-end developer, so maybe that doesn't help. Also lastly, I accidentally found that my company's windows 10 is working fine, |
I can confirm this with nuxt 2.14.12 on npm 7.4.3 and node 15.7.0
I can start the dev server and then work with the "root" page of my app, but as soon as I switch to different page, it stops working. |
@danielroe Unfortunately switching to |
workaround for nuxt/nuxt#7855
Encountered the same problem with a standard application, nuxt will eat up the whole RAM and crashes when you allocate more using e.g. https://stackoverflow.com/questions/52205500/nuxt-generate-fatal-error-ineffective-mark-compacts-near-heap-limit-allocation |
@MartinWeise A reproduction would be appreciated 🙃 |
@danielroe I got this error in a new nuxt app, it also reproduces with nuxt-edge. I've stripped it down to a barebones reproduction: https://github.com/adam-knights/adam-nuxt-demo-heap To reproduce just run You mentioned something around a build and then generate being an issue, and thats the case in the Dockerfile here. I also created a new app using an older create nuxt app template and can confirm I don't see the issue in 2.12.2 |
@adam-knights I can't reproduce a memory leak with that project. |
NuxtJS version v2.16.0-26938120.9247190c huge memory leak in dev mode and also in prod, I think here is problem related with nuxt link and nuxt i18n strategy prefix mode, this is rather unstable and I can say that it is unusable at the moment! <--- Last few GCs ---> [13848:00000165401FA9E0] 3398103 ms: Mark-sweep 2044.3 (2051.6) -> 2044.2 (2052.1) MB, 1902.7 / 0.1 ms (average mu = 0.072, current mu = 0.001) allocation failure scavenge might not succeed <--- JS stacktrace ---> ==== JS stack trace =========================================
Security context: 0x0064e70c08d1 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory |
@mirkofisic Always happy to take a look. Could you create a new issue with a reproduction please? 🙏 |
I am very busy but I will try to explain details: I have 2 subpages |
Same here
|
I would like to call attention here, is this maybe something that Nuxt or Vue should do automatically? |
Hello all, i am having memory leak in Nuxt.js in production. It's crazy, i looked at the code and nothing that indicates, i migrated from Laravel/Vue to Nuxt.js. The Vue.js code is essentially the same. I think the problem is within Nuxt.js. |
I'm facing the same issue guys, almost spent 3 days without any good luck to find a solution |
After 3 days of attempting some of the solutions outlined above, lots of additional searching and trial/error (and lots of cussing), the culprit for me was a |
I don't know if it's related to your issue, but we have 2GB RAM server which has 1 GB of swap space, we've been building our application with "nuxt build" successfully for a very long time (with a very big RAM usage though + running other processes with pm2), but yesterday after updating some of our project dependencies, we've encountered a problem with build, the build was not passing caused by too much RAM usage (even the swap space was full, and all pm2 processes were stopped). It was fixed by setting --max-old-space-size=2048 (with " export NODE_OPTIONS="--max-old-space-size=2048" "). We're using "nuxt build" command. [EDIT] after a few tests it turns out that, it is fixed only by using "--max-old-space-size=2048" and stopped pm2 all processes |
We are approaching the Nuxt 2 EOL date (June 30, 2024) - see this article for more information. This is advance warning that I'm going to close this issue then, as it's currently marked as a Nuxt 2 related bug. If it's a critical or security issue, please do comment and let me know, in case it is possible to address it before the EOL date. If it's a an issue you think is relevant for Nuxt 3, please feel free to open a fresh issue (or just comment here so I can update labels, etc.). 🙏 Thank you for your understanding and for your contribution to Nuxt. ❤️ |
It's the day, at last. Nuxt 2 is now marked end-of-life. My apologies we never got round to resolving this bug in the 2.x branch, but we do have to draw a line somewhere. Again, if you think this is still relevant for Nuxt going forward, please feel free to open a fresh issue (or just comment here so I can update labels, etc.). 🙏 |
Versions
Reproduction
I'm using
nuxt generate
with the memory benchmarking from #7412 (comment).I've reduced the generate.concurrency down to 1 and I can see in the logs that after "Generating pages with full static mode" it start's going through my pages and the heap memory just keeps on growing.
After about 100 pages generated it runs out of heap memory
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
.I'm using 3GB of heap memory with
node --max_old_space_size=3072 ./node_modules/.bin/nuxt generate
, sure I could increase this but with hundreds of pages it's not scalable.This wasn't happening in the older version of nuxt 2.12.2
What is Expected?
I expect that generating pages would have roughly flat memory usage and not keep on growing with each generated page.
What is actually happening?
Memory usage keeps growing with each generated page.
The text was updated successfully, but these errors were encountered: