#1033 Jest detecting memory leak on require of @pact-foundation/pact
Issue created by
Maxim-Filimonov
I have been investigating memory leak in our project and found that some of it comes from @pact-foundation/pact at least according to jest.
Software versions
Please provide at least OS and version of pact-js
•
OS: 13.0.1 (22A400)
•
Consumer Pact library: @pact-foundation/pact@10.4.0
•
Provider Pact library: N/A
•
Node Version: v16.15.0
Issue Checklist
Please confirm the following:
☑︎ I have upgraded to the latest
☑︎ I have the read the FAQs in the Readme
☑︎ I have triple checked, that there are
no unhandled promises in my code and have
read the section on intermittent test failures
☑︎ I have set my log level to debug and attached a log file showing the complete request/response cycle
☑︎ For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem
Reproduction repo
Expected behaviour
Jest shouldn’t be detecting leaks when requiring pact-foundation.
Actual behaviour
Jest detect memory leaks when not even using pact - only requiring it
Steps to reproduce
1. Go to
reproduction repo
2. Run
npm install
3. Run
npm test
4. See jest reporting leaks:
FAIL ./leak.test.js
● Test suite failed to run
EXPERIMENTAL FEATURE!
Your test suite is leaking memory. Please ensure all references are cleaned.
There is a number of things that can leak memory:
- Async operations that have not finished (e.g. fs.readFile).
- Timers not properly mocked (e.g. setInterval, setTimeout).
- Keeping references to the global scope.
at onResult (node_modules/@jest/core/build/TestScheduler.js:150:18)
at Array.map (<anonymous>)
pact-foundation/pact-js