Skip to content
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

Version 8.0.0 rc 9 throws memory leak #2612

Closed
agracia-foticos opened this issue Dec 11, 2023 · 43 comments
Closed

Version 8.0.0 rc 9 throws memory leak #2612

agracia-foticos opened this issue Dec 11, 2023 · 43 comments

Comments

@agracia-foticos
Copy link

agracia-foticos commented Dec 11, 2023

Environment

  • Operating System: Linux
  • Node Version: v20.5.1
  • Nuxt Version: 3.8.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

This graph its our application with i18n 8.0.0 rc 9, with one screaming frog crawl with 20 simultaneous threads and one Jmeter with 100 threads simultaneously.
The memory raises and the garbage doesnt recollect the memory (The drop that is seen is because we restart the server automatically when we reach a certain threshold)
image

The same situation (the same packages and config), but with i18n 8.0.0 rc 5 (only we change the version of this library)... the memory is stable.

image

Describe the bug

This graph its our application with i18n 8.0.0 rc 9, with one screaming frog crawl with 20 simultaneous threads and one Jmeter with 100 threads simultaneously.
The memory raises and the garbage doesnt recollect the memory (The drop that is seen is because we restart the server automatically when we reach a certain threshold)
image

The same situation (the same packages and config), but with i18n 8.0.0 rc 5 (only we change the version of this library)... the memory is stable.

image

Additional context

No response

Logs

No response

Copy link

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 Reproduction starter (v8 and higher)
👉 Reproduction starter (edge)

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@agracia-foticos
Copy link
Author

It's impossible to replicate our environment...

We can provide us our package.json and nuxt.config.ts ??

@BobbieGoede
Copy link
Collaborator

A minimal reproduction would of course help the most, but if you could provide package.json and nuxt config that would narrow down what features and dependencies could cause this 🙏.

@kazupon
Copy link
Collaborator

kazupon commented Dec 11, 2023

If possible, I would like to find out from which version this is happening.
Can you reproduce the memory leak in each between rc.6 and rc.9? 🙏

@agracia-foticos
Copy link
Author

A minimal reproduction would of course help the most, but if you could provide package.json and nuxt config that would narrow down what features and dependencies could cause this 🙏.

Package.json
{ "private": true, "scripts": { "dev": "nuxt dev", "build": "npx nuxi build", "generate": "nuxt generate", "preview": "nuxt preview", "clean": "npx nuxi cleanup", "stats": "npx nuxi analyze", "test": "wdio wdio.local.conf.ts" }, "type": "module", "devDependencies": { "@faker-js/faker": "^8.2.0", "@nuxt/image": "^1.0.0", "@nuxt/postcss8": "^1.1.3", "@nuxtjs/partytown": "^1.3.0", "@nuxtjs/tailwindcss": "^6.9.4", "@sidebase/nuxt-auth": "0.5.0", "@sidebase/nuxt-session": "^0.2.7", "@tailwindcss/typography": "^0.5.7", "@types/node": "^20.9.0", "@unlighthouse/nuxt": "^0.9.0", "@wdio/cli": "^8.20.2", "@wdio/globals": "^8.20.0", "@wdio/junit-reporter": "^8.20.0", "@wdio/local-runner": "^8.20.0", "@wdio/mocha-framework": "^8.20.0", "@wdio/spec-reporter": "^8.20.0", "autoprefixer": "^10.4.7", "cssnano": "^5.1.15", "eslint": "^8.53.0", "eslint-config-standard": "^17.0.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^6.1.1", "fs-extra": "^11.1.1", "mapbox-gl": "^2.15.0", "nuxt": "3.8.2", "nuxt-icon": "^0.4.0", "nuxt-mapbox": "^1.4.4", "nuxt-schema-org": "^2.1.2", "nuxt-security": "^0.13.0", "nuxt-viewport": "^2.0.3", "postcss": "^8.4.31", "postcss-import": "^15.1.0", "ts-node": "^10.9.1", "typescript": "^5.2.2", "wdio-chromedriver-service": "^8.1.1", "wdio-wait-for": "^3.0.7", "webdriverio": "^8.20.0" }, "dependencies": { "@adyen/adyen-web": "^5.53.2", "@headlessui/vue": "^1.6.7", "@nuxtjs/algolia": "^1.9.0", "@nuxtjs/i18n": "8.0.0-rc.5", "@pinia/nuxt": "^0.4.2", "@vueuse/nuxt": "^9.5.0", "@wdio/codemod": "^0.12.0", "chart.js": "^3.8.2", "defu": "^6.1.1", "env-cmd": "^10.1.0", "jscodeshift": "^0.14.0", "jsonminify": "^0.4.2", "jwt-decode": "^3.1.2", "mysql2": "^3.6.3", "next-auth": "4.21.1", "npx": "^10.2.2", "nuxt-api-party": "^0.21.3", "nuxt-swiper": "^1.2.2", "nuxt-vue3-google-signin": "^0.0.8", "pinia": "^2.0.22", "pinia-shared-state": "^0.3.0", "redis": "^4.6.10", "rsync": "^0.6.1", "tiny-emitter": "^2.1.0", "vue": "^3.3.8", "vue-chart-3": "^3.1.8", "vue-easy-lightbox": "^1.14.0", "vue-loading-skeleton": "^2.0.0-beta.1", "vue-recaptcha": "^2.0.3", "vue-tel-input": "^8.1.4", "webdriver": "^8.20.0", "winston": "^3.8.2", "winston-syslog": "^2.7.0" } }

nuxt.config.ts

`export default defineNuxtConfig({

srcDir : 'src/',

experimental: {
    asyncContext: false,// necessary to use: "useEvent" in the server part
    headNext: true,
    //clientFallback : true, //https://github.com/nuxt/nuxt/issues/21569
    defaults : {
        useAsyncData : {
            deep : false
        }
    },
    writeEarlyHints : false
},

modules : [
    '@nuxtjs/tailwindcss',
    'genesis-design-system/nuxt',
    '@nuxtjs/algolia',
    'nuxt-viewport',
    //'@nuxtjs/partytown',
    '@vueuse/nuxt',
    'nuxt-schema-org',
    'nuxt-icon',
    'nuxt-swiper',
    ['@pinia/nuxt', {
        imports: [                
            ['defineStore', 'definePiniaStore'] // automatically imports `usePinia()` as `usePiniaStore()`
        ]
    }],
    '@nuxtjs/i18n',
    '@sidebase/nuxt-auth',
    'nuxt-security',
    '@sidebase/nuxt-session',
    'nuxt-vue3-google-signin',
    "@nuxt/image",
    'nuxt-mapbox',
    'nuxt-api-party'
],

vite : { 
    optimizeDeps: {
        include: [ 'lodash-es' ],
    },
    build : {
    },
    server : {
        fs : {
            allow: ['../..']
        }
    },
    vue: {
        script: {
            fs: {
                fileExists(file: string) {
                    return existsSync(file);
                },
                readFile(file: string) {
                    return readFileSync(file, "utf-8");
                },
            },
        },
    },
},

image : {
    // The screen sizes predefined by `@nuxt/image`:
    screens: {
        xs    : 320,
        sm    : 640,
        md    : 768,
        lg    : 1024,
        xl    : 1280,
        xxl   : 1536,
        '2xl' : 1536
    },
    ipx: {
        maxAge: 604800,
    },
},

i18n : {
    defaultLocale : process.env.NUXT_PUBLIC_LANG,
    locales: [
                {code : process.env.NUXT_PUBLIC_LANG.toLowerCase(), file: `${process.env.NUXT_PUBLIC_LANG.toLowerCase()}.json`}
            ],
    langDir : 'locales',
},

nitro : {
    compressPublicAssets : {
        gzip   : true,
        brotli : true
    },
    output : {
        dir       : `./`,
        serverDir : `./server`,
        publicDir : `./public`            
    },
    prerender : {
        concurrency : 1
    },
},

telemetry : false,

algolia: {
    apiKey        : "asfdgagf",
    applicationId : "afgagfadfg"
},

schemaOrg: {
    host: "http://localhost:3000"
},

viewport: {
    /* Viewport options */
},

build: {
    transpile: ['chart.js', 'vue-chart-3', '@headlessui/vue', 'vue-easy-lightbox','unix-dgram'],
},

mapbox : {
    accessToken : 'sadfgadgadfgadgf'
},

})`

@agracia-foticos
Copy link
Author

If possible, I would like to find out from which version this is happening. Can you reproduce the memory leak in each between rc.6 and rc.9? 🙏

In rc5 works fine!

In rc 6 doesnt works
In rc 9 doesnt works

I dont test if rc7 and rc 8 fails

@thomaspaillot
Copy link

I reproduce and profile the memory leak with a fresh [email protected] install with only @nuxtjs/[email protected] and a page using the t function in the template block.

Like @agracia-foticos, I can confirm that there is no memory leak in version rc5. rc6 wouldn't build so I tested rc7, rc8 and rc9, all have the memory leak.

I profile the different build by running node --inspect .output/server/index.mjs and doing multiple heap snapshots with some loads between each.

Here's the snapshots for the rc5 version (memory is stable)
@nuxtjs:i18n@8 0 0-rc 5

Here's the snapshots for the rc7 version (memory is leaking)
@nuxtjs:i18n@8 0 0-rc 7

export default defineNuxtConfig({
  modules: [
    '@nuxtjs/i18n'
  ],
  i18n: {
    locales: [
      { code: 'en', iso: 'en', file: 'en.json', name: 'English' }
    ],
    defaultLocale: 'en',
    lazy: true,
    langDir: 'i18n/',
    detectBrowserLanguage: {
      useCookie: true,
      cookieKey: 'pn-i18n',
      alwaysRedirect: true
    }
  },
})

@calin-marian
Copy link

I can confirm that it's reproducible on rc6 too, as well as rc7, rc8 and rc9.

@BobbieGoede
Copy link
Collaborator

The latest edge release contains a fix for the (what was likely the larger) memory leak, please let me know if you can confirm this in your project! Installing it as alias: npm i -D @nuxtjs/i18n@npm:@nuxtjs/i18n-edge, you may need to delete node_modules and any lockfiles.

From my testing it seems like there is still a smaller memory leak present, I'm still working on finding the cause and fixing that.

@thomaspaillot
Copy link

thomaspaillot commented Dec 14, 2023

I can confirm that in my minimal reproductible test case, the main leak is not present anymore but I still see a smaller one like you. Thanks for the quick correction.

@thomaspaillot
Copy link

It seems that the small remaining leak comes from this line:

nuxtI18nOptions.baseUrl = extendBaseUrl(nuxtI18nOptions.baseUrl, {

@BobbieGoede
Copy link
Collaborator

It seems that the small remaining leak comes from this line:

nuxtI18nOptions.baseUrl = extendBaseUrl(nuxtI18nOptions.baseUrl, {

@thomaspaillot
You are likely running into the issue described here #2034 (comment), I have a PR lined up to resolve that #2621.

@agracia-foticos
Copy link
Author

I update to RC 10 but the memory leak persists:
image

Its smaller, but memory leak persists

@BobbieGoede
Copy link
Collaborator

@agracia-foticos
Can you check again with rc.11? If you're still experiencing this leak with rc.11 I will need more information to be able to debug it.

If a reproduction isn't possible I would at least like to know where and how you use this module, inside plugins, middleware, whether you use translations inside head tags, inside Pinia and so on. Hopefully we can get this fixed and get v8 stable! 😄

@agracia-foticos
Copy link
Author

@agracia-foticos Can you check again with rc.11? If you're still experiencing this leak with rc.11 I will need more information to be able to debug it.

If a reproduction isn't possible I would at least like to know where and how you use this module, inside plugins, middleware, whether you use translations inside head tags, inside Pinia and so on. Hopefully we can get this fixed and get v8 stable! 😄

Rc11, still persists memory leak
image

I use translation inside useHead
useHead({ title: ${t("about_us.title")} | ${siteConfig.brandName}, })

I don't use translations in stores, plugins and middleware

@s00d
Copy link
Contributor

s00d commented Dec 15, 2023

@agracia-foticos Can you check again with rc.11? If you're still experiencing this leak with rc.11 I will need more information to be able to debug it.
If a reproduction isn't possible I would at least like to know where and how you use this module, inside plugins, middleware, whether you use translations inside head tags, inside Pinia and so on. Hopefully we can get this fixed and get v8 stable! 😄

Rc11, still persists memory leak image

I use translation inside useHead useHead({ title: ${t("about_us.title")} | ${siteConfig.brandName}, })

I don't use translations in stores, plugins and middleware

Added useHead here https://github.com/s00d/max-call-err
No leakage on version 11, tested via ab

npm i
npm run build 
node .output/server/index.mjs 
ab -n 1000 -c 100 http://localhost:3000/

after 1000 requests, the RAM usage returned back and consumes less than 1 MB
If the problem still exists, it lies elsewhere

Copy link

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 Reproduction starter (v8 and higher)
👉 Reproduction starter (edge)

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@azhirov
Copy link

azhirov commented Dec 19, 2023

@agracia-foticos, perhaps your issue is related to using await before computed, where useNuxtApp().$i18n.t() is called: #2629

@agracia-foticos
Copy link
Author

@agracia-foticos, perhaps your issue is related to using await before computed, where useNuxtApp().$i18n.t() is called: #2629

I have multiple 'await stores' before computed properties with t() :(

@agracia-foticos
Copy link
Author

@agracia-foticos Can you check again with rc.11? If you're still experiencing this leak with rc.11 I will need more information to be able to debug it.

If a reproduction isn't possible I would at least like to know where and how you use this module, inside plugins, middleware, whether you use translations inside head tags, inside Pinia and so on. Hopefully we can get this fixed and get v8 stable! 😄

@BobbieGoede #2629 I think its the same issue, i have multiple t() into computed before await with stores

@agracia-foticos
Copy link
Author

I'm testing now remove experimental: asyncContext like latest comment of @szwenni #2629

@agracia-foticos
Copy link
Author

Versión 8 final estable produces memory leak also
image

@BobbieGoede
Copy link
Collaborator

Can you check if you're still experiencing the leak using the latest edge release? (npm i -D @nuxtjs/i18n@npm:@nuxtjs/i18n-edge@latest)

@BobbieGoede
Copy link
Collaborator

@agracia-foticos @szwenni
The leak should also be gone when using asyncContext with the latest edge release, curious to hear if it is resolved in your projects 🙏

@agracia-foticos
Copy link
Author

@agracia-foticos @szwenni The leak should also be gone when using asyncContext with the latest edge release, curious to hear if it is resolved in your projects 🙏

I will test it. I'll let you know with news

@agracia-foticos
Copy link
Author

@agracia-foticos @szwenni The leak should also be gone when using asyncContext with the latest edge release, curious to hear if it is resolved in your projects 🙏

When i launch 'npx nuxi build'

`Could not resolve module "@intlify/vue-i18n-bridge/lib/index.mjs" 8:30:47

at setupAlias (node_modules/@nuxtjs/i18n/dist/module.mjs:118:13)
at async setup (node_modules/@nuxtjs/i18n/dist/module.mjs:1478:5)
at async normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:2112:17)
at async installModule (node_modules/@nuxt/kit/dist/index.mjs:2415:95)
at async initNuxt (node_modules/nuxt/dist/index.mjs:3827:7)
at async loadNuxt (node_modules/nuxt/dist/index.mjs:3925:5)
at async Module.loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:2570:19)
at async Object.run (node_modules/nuxi/dist/chunks/build.mjs:73:18)
at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.4fde776c.mjs:1648:16)
at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.4fde776c.mjs:1639:11)

ERROR Could not resolve module "@intlify/vue-i18n-bridge/lib/index.mjs" `

@BobbieGoede
Copy link
Collaborator

BobbieGoede commented Jan 10, 2024

@agracia-foticos
Have you tried removing node_modules and lockfiles and running install again? That should solve dependency issues updating from older release candidate versions.

@agracia-foticos
Copy link
Author

agracia-foticos commented Jan 10, 2024

@agracia-foticos Have you tried removing node_modules and lockfiles and running install again? That should solve dependency issues updating from older release candidate versions.

I test crawling our site with screaming frog
This is the graph with 5 simultaneous threads. Memory leak seams to dissapear
image

This is the graph with 30 simultaneous threads. Memory leak seams to dissapear.
image

@agracia-foticos
Copy link
Author

With anothen tool (Jmeter) memory leak persists :(

image

@BobbieGoede
Copy link
Collaborator

That's odd, the memory usage should still climb to a certain extent (this mostly depends on the amount of messages being loaded) during requests but lower again after about 10-20~ seconds. I have some changes in mind to improve the overall memory usage (won't necessarily fix leaks) but unfortunately these changes will likely take weeks or months to implement.

Do you know what the difference is in method between Screaming Frog and Jmeter? I'm not familiar with these tools but I can't think of a reason for the memory leak to be present with one and not the other.

To absolutely ensure you're using the updated dependencies during your tests, you could try installing vue-i18n@^9.9.0 as well as the latest edge release of @nuxtjs/i18n. If the leak persists, I can only assume that your project triggers this (or another) leak in a different way than we have been able to find and reproduce thus far.

@agracia-foticos
Copy link
Author

agracia-foticos commented Jan 10, 2024

That's odd, the memory usage should still climb to a certain extent (this mostly depends on the amount of messages being loaded) during requests but lower again after about 10-20~ seconds. I have some changes in mind to improve the overall memory usage (won't necessarily fix leaks) but unfortunately these changes will likely take weeks or months to implement.

Do you know what the difference is in method between Screaming Frog and Jmeter? I'm not familiar with these tools but I can't think of a reason for the memory leak to be present with one and not the other.

To absolutely ensure you're using the updated dependencies during your tests, you could try installing vue-i18n@^9.9.0 as well as the latest edge release of @nuxtjs/i18n. If the leak persists, I can only assume that your project triggers this (or another) leak in a different way than we have been able to find and reproduce thus far.

They are similar, but with Jmeter you can determine the crawling speed much better. To measure page loads we better use Jmeter.

I will try to install implicitly vue-i18n@^9.9.0 with edge @nuxtjs/i18n and I'll tell you news

@agracia-foticos
Copy link
Author

our npm list

├── @adyen/[email protected] ├── @faker-js/[email protected] ├── @headlessui/[email protected] ├── @nuxt/[email protected] ├── @nuxt/[email protected] ├── @nuxtjs/[email protected] ├── @nuxtjs/i18n@npm:@nuxtjs/[email protected] ├── @nuxtjs/[email protected] ├── @nuxtjs/[email protected] ├── @pinia/[email protected] ├── @sidebase/[email protected] ├── @sidebase/[email protected] ├── @tailwindcss/[email protected] ├── @types/[email protected] ├── @unlighthouse/[email protected] ├── @vueuse/[email protected] ├── @wdio/[email protected] ├── @wdio/[email protected] ├── @wdio/[email protected] ├── @wdio/[email protected] ├── @wdio/[email protected] ├── @wdio/[email protected] ├── @wdio/[email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├─┬ [email protected] -> ./../genesis-design-system │ ├── @babel/[email protected] │ ├── @babel/[email protected] │ ├── @headlessui/[email protected] │ ├── @heroicons/[email protected] │ ├── @iconify/[email protected] │ ├── @mdx-js/[email protected] │ ├── @nuxt/[email protected] │ ├── @nuxtjs/[email protected] │ ├── @storybook/[email protected] │ ├── @storybook/[email protected] │ ├── @storybook/[email protected] │ ├── @storybook/[email protected] │ ├── @storybook/[email protected] │ ├── @storybook/[email protected] │ ├── @storybook/[email protected] │ ├── @storybook/[email protected] │ ├── @storybook/[email protected] │ ├── @storybook/[email protected] │ ├── @tailwindcss/[email protected] │ ├── @tailwindcss/[email protected] │ ├── @vue/[email protected] │ ├── @vue/[email protected] │ ├── @vue/[email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ ├── [email protected] │ └── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected]

memory leak persists
image

@BobbieGoede
Copy link
Collaborator

@agracia-foticos
I have tried to trigger a memory leak locally with several reproduction projects but so far I'm unable to replicate it. If it's not possible to create a minimal reproduction, would it be possible for me to access your project to try and debug this issue?

@agracia-foticos
Copy link
Author

@agracia-foticos I have tried to trigger a memory leak locally with several reproduction projects but so far I'm unable to replicate it. If it's not possible to create a minimal reproduction, would it be possible for me to access your project to try and debug this issue?

Sorry, our project is a private ecommerce and it is not possible to give access to personnel outside the company.
Could you help us provide us with the information of a Node Profiler?

@BobbieGoede
Copy link
Collaborator

Ah I see.

Could you help us provide us with the information of a Node Profiler?

To get an idea of what could be leaking I use Chrome devtools to take heap snapshots before and after the leak and compare these, you can read on how to do this here: https://nodejs.org/en/guides/diagnostics/memory/using-heap-snapshot.

Finding what exactly is leaking is still not very straightforward, if I see something that could hint to a certain feature leaking I try and trigger the leak in a minimal reproduction to confirm and further narrow down the leak. Previously it was the messages leaking (it could possibly still be in certain configs), so using a large locale file with varying message types (arrays, nested keys) made it easier to see if a leak was triggered (the locale file in this reproduction for example: https://github.com/BobbieGoede/i18n-memory-leak).

There's probably other ways to debug memory leaks in a node process that I'm not aware of, but maybe this will help you identify the issue, let me know if you have any questions!

@dreitzner
Copy link

Same issue here as we upgraded from /@nuxtjs/[email protected] to /@nuxtjs/[email protected].

image

Running on AWS EC2 with node18.19.0

We'll try to update the rc version step by step to maybe confirm where it breaks.

@BobbieGoede
Copy link
Collaborator

@dreitzner
Can you check if you're still experiencing this issue with the latest edge release (npm i -D @nuxtjs/i18n@npm:@nuxtjs/i18n-edge@latest)? You may have to remove node_modules and lockfiles first, and update vue-i18n to latest as well if you happen to have its version pinned.

@dreitzner
Copy link

@BobbieGoede I created an internal ticket. I'll follow up here when I have more infos 😉

@dreitzner
Copy link

dreitzner commented Jan 24, 2024

@BobbieGoede

I ran a quick load test locally:

  • nuxt 3.9.1
  • [email protected]
  • Windows11 with WSL2 (prod runs on AWS EC2, that has the same issue, local testing is just quicker)
  • with pnpm preview

Test setup with k6

import http from 'k6/http';

export let options = {
    stages: [
        { duration: '30s', target: 5 },
        { duration: '30s', target: 10 },
        { duration: '30s', target: 15 },
        { duration: '30m', target: 20 },
    ],
};

export default function () {
    http.get('http://localhost:3000/', );
}

Test results with version:

  • v8.0.0-rc.5: passes after 31m30s
  • v8.0.0-rc.6: fails after 3m40s
  • v8.0.0-rc.7: fails after 3m40s
  • v8.0.0-rc.8: fails after 3m38s
  • v8.0.0-rc.9: fails after 4m04s
  • v8.0.0-rc.10: fails after 3m45s
  • v8.0.0-rc.11: fails after 3m50s
  • v8.0.0: fails after 3m40s
  • v8.0.0-28432155.c9bdcd7: fails after 3m30s

Console output

<--- Last few GCs --->

[35353:0x6ace870]   219588 ms: Scavenge 1961.0 (2052.4) -> 1957.8 (2060.4) MB, 4.9 / 0.0 ms  (average mu = 0.373, current mu = 0.602) allocation failure; 
[35353:0x6ace870]   219596 ms: Scavenge 1966.6 (2068.2) -> 1965.5 (2068.2) MB, 4.6 / 0.0 ms  (average mu = 0.373, current mu = 0.602) allocation failure; 
[35353:0x6ace870]   219603 ms: Scavenge 1973.9 (2075.3) -> 1972.6 (2091.3) MB, 4.1 / 0.0 ms  (average mu = 0.373, current mu = 0.602) allocation failure; 


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb95b60 node::Abort() [node]
 2: 0xa9a7f8  [node]
 3: 0xd6f2f0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xd6f697 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xf4cba5  [node]
 6: 0xf4daa8 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
 7: 0xf5dfb3  [node]
 8: 0xf5ee28 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0xf3978e v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
10: 0xf3ab57 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
11: 0xf1bd2a v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
12: 0x12e114f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
13: 0x170deb9  [node]

 ERROR  Command was killed with SIGABRT (Aborted): node ./server/index.mjs                                                                                                                           9:37:10 AM

  at makeError (node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/chunks/index3.mjs:625:11)
  at handlePromise (node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/chunks/index3.mjs:1821:26)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async Object.run (node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/chunks/preview.mjs:130:5)
  at async runCommand$1 (node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/shared/nuxi.4fde776c.mjs:1648:16)
  at async runCommand$1 (node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/shared/nuxi.4fde776c.mjs:1639:11)
  at async runMain$1 (node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/shared/nuxi.4fde776c.mjs:1773:7) 



 ERROR  Command was killed with SIGABRT (Aborted): node ./server/index.mjs                                                                                                                           9:37:10 AM

 ELIFECYCLE  Command failed with exit code 1.

@BobbieGoede
Copy link
Collaborator

v8.0.0@edge: fails after less than 1/2 time

Ah that's unfortunate to hear, I'm assuming you are using @nuxtjs/i18n-edge, can you share your project or a minimal reproduction? I have no idea what else could still be causing a memory leak, the leaks in the reproductions provided so far I have been able to fix.

@dreitzner
Copy link

@BobbieGoede I updated the test results.

Unfortunatly I can't share the repo, but I'd be more than happy to set up a call with you and do live debugging.

Feel free to reach out:

@agracia-foticos
Copy link
Author

¡¡VERSION 8.0.1 works fine!!

@agracia-foticos
Copy link
Author

I close the issue! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants