You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Possible memory leak when using real Vuex store in plugins #1787
I have a project with 8,000+ tests using mocha, many of which create a real Vuex store. Recently we have migrated to Vue3 and test-utils v2. After the upgrade a memory leak is causing the test suite to fail as it runs out of heap space. At this time it seems to be adding a plugin (store) when mounting causes the issue, though not fully sure if there is additional cleanup I must be doing that isn't mentioned in docs.
To Reproduce
I have created the HelloWorld project from vue-cli (webpack, vuex, mocha), and modified the one and only test in that project:
Looped single test many times
created a store and added to global.plugins for each test
When I inspect this while running I can observe each test is leaking memory. Simply, not creating store and not pass in plugins, I no longer see the leak.
Expected behavior
Run entire test suite without getting out of heap exception.
Related information:
@vue/test-utils version: 2.1.0
Vue version: 3.2.39
node version: 14.18.1 and 16.17.1
vuex version 4.0.2
@vue/cli-plugin-* version ~4.5.19
Additional context
A few other things I have tested:
creating one store for all tests and setting with config.global.plugins = [store], still saw leak
created store but did not actually use in config.global.plugins or in shallowMount, did not see leak
@freakzlike - Thanks for the suggestion, in my original project I am doing this and still see the issue. I didn't show this in original post as I was trying to make minimal changes to the original test from vue-cli. However, I added unmount in repo listed above and still see the issue
Activity
[-]Bug: [/-][+]Bug: Possible memory leak when using real Vuex store in plugins[/+]cexbrayat commentedon Sep 30, 2022
@rappjt Thanks for raising this issue. Would you mind pushing your repro to a GitHub repo so someone can take an easy look?
freakzlike commentedon Sep 30, 2022
Can you also try again with
wrapper.unmount()orenableAutoUnmount? Maybe this makes a differencerappjt commentedon Sep 30, 2022
@cexbrayat - Thank you for the quick response, here is a repo I hope will demonstrate the issue https://github.com/rappjt/vuejs-test-utils-plugin-vuex-memory-issue
@freakzlike - Thanks for the suggestion, in my original project I am doing this and still see the issue. I didn't show this in original post as I was trying to make minimal changes to the original test from vue-cli. However, I added
unmountin repo listed above and still see the issuefreakzlike commentedon Oct 4, 2022
I was able to reproduce it within VTU tests and I could break it down to:
test-utils/src/vueWrapper.ts
Line 125 in 5c1dceb
The changes in #1793 have reduced the memory in my test case from ~700 MB to ~300 MB so there is still some more optimization needed