nock icon indicating copy to clipboard operation
nock copied to clipboard

Fix Jest memory leak from nock.restore()

Open ForestBeaver opened this issue 3 years ago • 3 comments

Jest appears to be losing reference to the patched http and https libs when required inside a loop.

Resolves https://github.com/nock/nock/issues/2383

ForestBeaver avatar Oct 27 '22 14:10 ForestBeaver

@gr2m is there a way we can get this in? this is the only barrier to my adoption of nock and this PR seems to be alright

idfunctor avatar Jan 03 '23 15:01 idfunctor

@gr2m is there a way we can get this in? this is the only barrier to my adoption of nock and this PR seems to be alright

Thank you for testing and confirming that it works for you!

We need a test that prevents us from future regression. Could you help out with that?

gr2m avatar Jan 10 '23 00:01 gr2m

@gr2m Any chance this gets added any time soon? I understand the ask for a test to prevent future regression, but short of adding a jest dependency and running a test with --detectLeaks, that seems like a non-trivial ask. The change on the other hand, seems pretty straightforward. It definitely seems better to not require both modules twice, imho.

I'd love to add nock to my current project at work, but I'm finding it very difficult to work around this issue (which in the worst case, seems to be inefficient usage of require), and removing --detectLeaks is not an option for me.

mostlylikeable avatar Mar 27 '23 00:03 mostlylikeable