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

MockHttpSocket and MockHttpAgent are not being garbage collected #2405

Open
4 tasks done
rossipedia opened this issue Jan 4, 2025 · 0 comments
Open
4 tasks done

MockHttpSocket and MockHttpAgent are not being garbage collected #2405

rossipedia opened this issue Jan 4, 2025 · 0 comments
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node

Comments

@rossipedia
Copy link

rossipedia commented Jan 4, 2025

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 18 or higher

Node.js version

22.12.0

Reproduction repository

https://github.com/rossipedia/msw-leak-test

Reproduction steps

Instructions are in the reproduction repo, but they are essentially:

  1. clone repro
  2. npm install
  3. ./demo.sh

Current behavior

Note

This is a follow up to my colleague's issue #2390

Enabling MSW with no handlers and then load-testing using ab causes heap usage to balloon, even when manually invoking garbage collection.

As best I can tell, the largest percentage of retained objects are primarily:

  • MockHttpSocket
  • MockHttpAgent

I do not believe this is related to express, as only ClientRequest is intercepted, and I don't think express or http.createServer use ClientRequest, only IncomingMessage and ServerResponse (I could be wrong about that though).

Expected behavior

Memory usage should be stable under load when simply enabling MSW in a node application.

@rossipedia rossipedia added bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node labels Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node
Projects
None yet
Development

No branches or pull requests

1 participant