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

Devtools integration leads to memory leak in Nuxt SSR #4963

Open
2 of 5 tasks
madskronborg opened this issue Dec 16, 2024 · 2 comments
Open
2 of 5 tasks

Devtools integration leads to memory leak in Nuxt SSR #4963

madskronborg opened this issue Dec 16, 2024 · 2 comments
Labels
🐛 bug Unintended behavior 💨 performance A performance issue or gains

Comments

@madskronborg
Copy link

madskronborg commented Dec 16, 2024

What happened?

We started experiencing memory leaks after rendering forms on the server (we previously had wrapped them in ClientOnly).

What we are seeing in local production builds with Node debugging in Chrome Devtools is that the DEVTOOLS_FORMS object keeps expanding with a reference to refreshInspector function when scouring through the heatmap. Since objects in the DEVTOOLS_FORMS object contains references to Vue component instances, it grows quite significantly.

Our investigations lead to the conclusion, that if we manually set NODE_ENV to production the memory leaks disappears.

I am not quite sure how it happens, but it seems like the value of process.env.NODE_ENV in vee-validates code is read before it is set to production in vite/nuxt resulting in devtools being registered on the server - even in production builds. However, I am not sure devtools should ever be registered on the server?

Reproduction steps

  1. Setup custom Form component with useForm in a Nuxt project, build it and launch it in production mode with node .output/server/index.mjs
  2. Server render the Form while having Node debugging enabled
  3. Record heatmap, reload x times, record heatmap and watch allocation of form contexts grow - maintained in the DEVTOOLS_FORMS object
    ...

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

No response

Demo link

No demo link available. A reproduction can be created if required.

Code of Conduct

@logaretm
Copy link
Owner

logaretm commented Dec 16, 2024

I believe we could just skip doing anything if the environment is SSR since Devtools integration is a client-only thing.

I cannot verify this bug, but I could see it happening and it wouldn't affect anything, so I will work on doing that. Thanks for reporting this.

@logaretm logaretm added 🐛 bug Unintended behavior 💨 performance A performance issue or gains labels Dec 16, 2024
@madskronborg
Copy link
Author

I believe we could just skip doing anything if the environment is SSR since Devtools integration is a client-only thing.

I cannot verify this bug, but I could see it happening and it wouldn't affect anything, so I will work on doing that. Thanks for reporting this.

Thank you for the quick response and that sounds great.

Really appreciate the help 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Unintended behavior 💨 performance A performance issue or gains
Projects
None yet
Development

No branches or pull requests

2 participants