-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
Possible memory leak in nodejs interception #710
Comments
Thank you for reporting this, @mathanpec! Please, do you have any insights as to where the memory heap originates from within MSW? Any help on this matter is highly appreciated. |
I have experienced the same issue some time ago when I was testing monkey patching. |
Hi @kettanaito, So I tried profiling the runs and this is what I could find, You can see |
That's a great observation, @mathanpec! I've opened a related issue in the interceptors repository. I think the fix should be straightforward—restore the patched version to the already stored original class. Please, would you be interested in making such a pull request happen? |
Hi @kettanaito, I did try restoring the patch version to the already stored original class. But still I am seeing heap memory is increasing consistently as shown in the image below though previous recursive And in the heap profile I couldn't find anything recursive now but I could see multiple copies of the same msw index file in memory as shown below. But I am not sure whether it is very relevant to the issue. |
Hi @kettanaito, As mentioned in this issue comment, I tried removing the monkey patching of PR for the same: mswjs/interceptors#116 |
Hi @kettanaito, Can you pls take a look into this and let me know your thoughts on this? |
Hey, @mathanpec. I've commented on the pull request. Will have to check it out and get back to you. Thank you for your work on this, it looks great! |
Hi @kettanaito, Thanks for looking into this and closing on this :) And Thanks a lot for this excellent library. Also would be able to tell approximately when can we expect this fix to get released? |
Thank you for the contribution, @mathanpec! |
Describe the bug
A clear and concise description of what the bug is.
I have a simple repo with 16 test files where every test file does the same thing of firing a simple fetch call and asserting for the response from the MSW handler. But when we run all the test files one after the other the heap usage keeps increasing. But when I comment the MSW server instantiation and other MSW related code heap memory stays constant.
Environment
msw: 0.28.2
nodejs: v12.14.0
npm: 6.13.4
To Reproduce
Steps to reproduce the behavior:
https://github.com/mathanpec/msw-memory-leak-test
yarn install
node --expose-gc ./node_modules/.bin/jest --silent --runInBand --detectOpenHandles --logHeapUsage
node --expose-gc
and running GC in the AfterAll step to make sure there are no unused memory is left between test files.Expected behavior
Memory heap should be consistent between every file runs or there should be a very minimal change. Check the following screenshot from the same repo without MSW server initialisation and handlers
The text was updated successfully, but these errors were encountered: