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(adapter-node-http): Remove module monkey patching on disconnect #369

Merged
merged 1 commit into from
Nov 18, 2020

Conversation

woodenconsulting
Copy link
Contributor

@woodenconsulting woodenconsulting commented Nov 18, 2020

Description

Fixes a memory leak with Jest due to native module monkey patching. More details in the issue I filed here. Note that I did not add any tests; implementing tests to assert the existence of a memory leak is not simple, but the changes here are. This is easily demonstrated in any jest test suite using polly with the node-http adapter by running the following command:

jest --coverage --verbose --colors --logHeapUsage --runInBand --detectLeaks

Motivation and Context

Memory leaks are bad :)

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have added tests to cover my changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • My code follows the code style of this project.
  • My commits and the title of this PR follow the Conventional Commits Specification.
  • I have read the contributing guidelines.

@woodenconsulting woodenconsulting changed the title fix(adapter-node-https): remove native module monkey patching on disconnect fix(adapter-node-http): Remove module monkey patching on disconnect Nov 18, 2020
@@ -120,6 +121,11 @@ export default class HttpAdapter extends Adapter {
const module = modules[moduleName];
const { request, get, globalAgent } = module;

this[moduleName] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'll probably end up renaming this but don't feel like blocking the PR on it :)

@jasonmit jasonmit merged commit 0cec43a into Netflix:master Nov 18, 2020
@jasonmit
Copy link
Contributor

Thanks for catching & fixing the memory leak - they're rarely fun to track down so much appreciated 🙏

@jasonmit
Copy link
Contributor

Fixes #370

@offirgolan
Copy link
Collaborator

Released with v5.0.2

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.

3 participants