Memory leaking after v14 upgrade
Please avoid duplicates
- I checked all open bugs and none of them matched my problem.
Reproducible test case
No example test case
Nock Version
^14.0.6
Node Version
v22.17.1
TypeScript Version
No response
What happened?
When we bumped nock from v13 to v14 on our production system some of our pods start leaking memory, only by requiring nock and loading with interceptors. By checking our heap dump, we found that a lot of related mock stuff was being loaded and not deleted after the requests. We believe that there are related with interceptors upgrade, and that are load as soon as we call require('nock').
In that case the issue was on our side, one of ours clients were requiring nock on a index to configure the mocks, that end up being loaded to our system services making a chain of dependencies that required nock when launched in production.
We fixed this issue in production by eager loading nock only when we call our clients mocks and that way not being required in production. But the root cause itself of the leak was not addressed. The issue was only visible in production when a huge number of requests were made to the service.
After the deploy, that only bumped the client to eager load nock our memory leak was fixed.
Just trying to raise awareness for this issue and sorry for the lack of more deep information and context.
Thanks in advance
Would you be interested in contributing a fix?
- yes
Source: nock/nock