i18n: Version 8.0.0 rc 9 throws memory leak

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: npm@9.8.0
  • 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

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 3
  • Comments: 43 (1 by maintainers)

Most upvoted comments

¡¡VERSION 8.0.1 works fine!!

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

I reproduce and profile the memory leak with a fresh nuxt@3.8.2 install with only @nuxtjs/i18n@8.0.0-rc.7 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
    }
  },
})

@agracia-foticos, perhaps your issue is related to using await before computed, where useNuxtApp().$i18n.t() is called: https://github.com/nuxt-modules/i18n/issues/2629

I close the issue! Thank you very much!

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

@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 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 @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 @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, 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 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

@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! 😄

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? 🙏