Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Jest complains about memory leak #1

Open
zaqqaz opened this issue May 24, 2019 · 6 comments
Open

Jest complains about memory leak #1

zaqqaz opened this issue May 24, 2019 · 6 comments
Labels
bug Something isn't working

Comments

@zaqqaz
Copy link

zaqqaz commented May 24, 2019

Steps to reproduce:

  1. add jest-environment-jsdom-fourteen to the project
  2. run jest with --detectLeaks flag

Result:

  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.
@ianschmitz
Copy link
Owner

Thanks for filing the issue @zaqqaz.

I've copied the latest logic from jest-environment-jsdom which I believe has sorted the issue.

I have published 1.0.0-alpha.0 which has removed the warning in my testing. Would you mind trying out the new version and let me know if it fixes the warning?

ianschmitz added a commit that referenced this issue May 25, 2019
@ianschmitz ianschmitz added the bug Something isn't working label May 25, 2019
@ianschmitz
Copy link
Owner

I've done some more testing and it appears that i'm still seeing the warning. The warning disappears when using the same version of jsdom that Jest uses. However when i use 14 the warning appears.

Looks like it will need some more investigation.

@ianschmitz
Copy link
Owner

/cc @SimenB sorry to ping you. Wanted to bring to your attention as you guys might run into this when you eventually drop Node 6 support and bump jsdom.

From what I can tell this project (as well as jest-environment-jsdom) is following the recommended practices from jsdom: https://github.com/jsdom/jsdom#closing-down-a-jsdom.

Possibly related issues:
jsdom/jsdom#2198
jsdom/jsdom#2370

@SimenB
Copy link

SimenB commented May 25, 2019

Does it happen with jsdom 15?

@ianschmitz
Copy link
Owner

It does indeed. https://github.com/theneva/jest-environment-jsdom-thirteen also gives the same memory leak warning.

I have a package up for jsdom 15 which has identical source to this one - https://github.com/ianschmitz/jest-environment-jsdom-fifteen.

@SimenB
Copy link

SimenB commented May 25, 2019

Odd - just empty test and jest's own source for the env but using a newer jsdom? I'd have to dig into it

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants