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

Memory leak reported by Jest #1516

Closed
2 tasks done
tmorell opened this issue Oct 28, 2020 · 3 comments
Closed
2 tasks done

Memory leak reported by Jest #1516

tmorell opened this issue Oct 28, 2020 · 3 comments

Comments

@tmorell
Copy link

tmorell commented Oct 28, 2020

Describe the bug

  • Node.js version: 14.8.0
  • OS & version: Manjaro 5.4.67

Actual behavior

Jest is reporting a memory leak, "Your test suite is leaking memory.".

Expected behavior

There should be no such report.

Code to reproduce

import got from "got";

test("just a test", () => {
    expect(true).toBeTruthy();
});

// Not even called, but forcing load
function loadIt(): void {
    console.log(got.name);
}

It does not happen with other packages, for example replacing got with express or Mongodb.

Using:
Jest: 26.6.1
ts-jest: 26.4.3

jest.config.js

module.exports = {
    preset: 'ts-jest',
    testEnvironment: 'node'
};

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.
@sindresorhus
Copy link
Owner

What exactly is leaking? Does Jest show a trace log or something? There's nothing actionable in this report. Jest has also had many false-positives with the memory leak reporting in the past.

@tmorell
Copy link
Author

tmorell commented Oct 28, 2020

I was able to trace it to this specific global reference:
./source/core/index.ts

const globalDnsCache = new CacheableLookup();

@szmarczak
Copy link
Collaborator

There is no memory leak, it's a false-positive by Jest. Related with jestjs/jest#9982

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

No branches or pull requests

3 participants