Skip to content
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

Fix Jest memory leak from nock.restore() #2407

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ForestBeaver
Copy link

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

Resolves #2383

@idfunctor
Copy link

@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

@gr2m
Copy link
Member

gr2m commented Jan 10, 2023

@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?

@mostlylikeable
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jest leaking memory even after calling nock.restore()
4 participants