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

Jest detecting memory leak on require of @pact-foundation/pact #1033

Open
5 tasks done
Maxim-Filimonov opened this issue Dec 23, 2022 · 4 comments
Open
5 tasks done
Labels
bug Indicates an unexpected problem or unintended behavior smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear

Comments

@Maxim-Filimonov
Copy link

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>)
@Maxim-Filimonov Maxim-Filimonov added the bug Indicates an unexpected problem or unintended behavior label Dec 23, 2022
@Maxim-Filimonov
Copy link
Author

I added some extra tests to the reproduction repo.
It looks like it has something to do with pino-pretty transport configuration.
Looks like it might need separate issue in pact-core. Any thoughts?

@TimothyJones
Copy link
Contributor

First off, thank you SO MUCH for the repo!

Secondly, I'm not hugely surprised that pino is a problem. Probably we should just replace pino with something else. Pact doesn't need a fully functional logger, just something that prints out timestamps, version numbers, and strings.

@mefellows
Copy link
Member

Thanks Maxim - this is awesome!

Secondly, I'm not hugely surprised that pino is a problem. Probably we should just replace pino with something else. Pact doesn't need a fully functional logger, just something that prints out timestamps, version numbers, and strings.

Exactly. I think this is the best approach to resolve this, albeit if it's a problem with Pino we ought to raise an upstream issue there also. I'll pick that job up when we get to this.

@mefellows mefellows added the smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear label Aug 18, 2023
@github-actions
Copy link

👋 Hi! The 'smartbear-supported' label has just been added to this issue, which will create an internal tracking ticket in PactFlow's Jira (PACT-1255). We will use this to prioritise and assign a team member to this task. All activity will be public on this ticket. For now, sit tight and we'll update this ticket once we have more information on the next steps.

See our documentation for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear
Projects
Status: New Issue
Development

No branches or pull requests

3 participants