Closed aq1018 closed 2 months ago
Hi, @aq1018. Thanks for reporting this!
Can you please try this in Vite? We are not addressing Jest-related issues (see this). Until we can confirm this is happening in modern test runners, I will close the issue.
Hi @kettanaito,
I create a new branch on my test repo to use vitest
, and it does not leak memory.
I'm sold on vitest
.
Prerequisites
Environment check
msw
versionNode.js version
v22.8.0
Reproduction repository
https://github.com/think-life/msw-memory-leak
Reproduction steps
Positive Test
npm install
node --expose-gc --no-compilation-cache ./node_modules/.bin/jest --silent --runInBand --detectOpenHandles --logHeapUsage
You will see something like:
Notice the heap size keeps increasing.
Note, I added
global.gc()
inafterAll
so that GC is run at the end of each test suite.Negative Test
package.json
file, and change themsw
version number to2.4.3
.npm install
node --expose-gc --no-compilation-cache ./node_modules/.bin/jest --silent --runInBand --detectOpenHandles --logHeapUsage
You will see something like this:
Although it is still increasing in size, the magnitude is much smaller.
Current behavior
Memory usage keep increasing. It seems the interaction between
@msw/interceptors
,supertest
, andnestjs
server is causing memory not being GC'ed properly.Expected behavior
Memory usage should be relatively stable.