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

Running Jest with yarn pnp enabled and node v20 leaks memory #5399

Closed
1 task
yossizahn opened this issue Apr 21, 2023 · 3 comments
Closed
1 task

Running Jest with yarn pnp enabled and node v20 leaks memory #5399

yossizahn opened this issue Apr 21, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@yossizahn
Copy link

Self-service

  • I'd be willing to implement a fix

Describe the bug

The following combination of circumstances causes a memory leak of approx. 200mb per second on my machine:

  • yarn with pnp enabled
  • node v20
  • yarn jest --watch

I don't know if this is a yarn issue or a nodejs issue or a jest issue
I can only reproduce the problem when all the conditions are met (yarn pnp, node 20, jest --watch)

To reproduce

I am not sure how to test for a memory leak using sherlock

I have created minimal reproduction here: https://github.com/yossizahn/yarn-pnp-jest-node20-memleak

Environment

System:
    OS: macOS 13.3.1
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 20.0.0 - /private/var/folders/6t/cgb4q3vj0tngmc63b3_t3l1h0000gn/T/xfs-66d5c86b/node
    Yarn: 3.5.0 - /private/var/folders/6t/cgb4q3vj0tngmc63b3_t3l1h0000gn/T/xfs-66d5c86b/yarn
    npm: 9.6.4 - ~/.nvm/versions/node/v20.0.0/bin/npm

Additional context

No response

@yossizahn yossizahn added the bug Something isn't working label Apr 21, 2023
@arcanis
Copy link
Member

arcanis commented Apr 21, 2023

Probably caused by nodejs/node#47566

@merceyz
Copy link
Member

merceyz commented Apr 21, 2023

You're running into nodejs/node#47566, if you don't need ESM support you can disable it to avoid the upstream bug.

yarn config set pnpEnableEsmLoader false
yarn install

https://yarnpkg.com/configuration/yarnrc#pnpEnableEsmLoader

@yossizahn
Copy link
Author

yossizahn commented Apr 21, 2023

Thanks!
(I spent hours isolating this bug 😅, I'm happy the cause has been identified already)

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

No branches or pull requests

3 participants