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

mingo + ts-jest creates memory leak to crash #145

Closed
j opened this issue Jun 19, 2020 · 6 comments
Closed

mingo + ts-jest creates memory leak to crash #145

j opened this issue Jun 19, 2020 · 6 comments

Comments

@j
Copy link

j commented Jun 19, 2020

Latest mingo with ts-jest creates memory leak / heap limit error.

Here's a simple repro: https://github.com/j/mingo-error

@kofrasa
Copy link
Owner

kofrasa commented Jul 9, 2020

Thanks a lot for the repro project. This is quite a weird issue to debug.

I haven't delved deeper into the node memory management to fully understand what could be happening as I suspect it would be an unnecessary rabbit hole.

Nonetheless I found these possibly related issues searching the jest project .

It is rather unlikely that querying a single object should cause GC issues. Over 500 unit tests run for mingo without any memory problems. The culprits if any would be the esm module introduce in 3.0.0 or jest itself. The shear number of memory leak issues open with the jest project leads me to believe it is responsible.

Are you using the same version of jest without error against older versions of mingo (e.g 2.x.x without ESM support)?

@kofrasa
Copy link
Owner

kofrasa commented Jul 9, 2020

See comment jestjs/jest#7874 (comment) which suggests the same type of problem described in this issue.

Please open an issue or add your vote to a relevant one in the jest project.

@j
Copy link
Author

j commented Jul 10, 2020

@kofrasa

Yes, I have dozens of dependencies and a huge mono-repo under one jest test suite, and it was just the mingo v3 version that caused the crash. The error mentioned esm from what I remember. Reverting back to 2.x.x fixed the issue, so I'm running the old version of mingo ATM. I used the same versions of everything else and tracked it down to mingo.

@j
Copy link
Author

j commented Jul 10, 2020

You can clone my repository, set mingo to 2.x and tests will pass.

@kofrasa
Copy link
Owner

kofrasa commented Jul 11, 2020

The fingers point to the dependency on esm. Something is amiss in how it interacts with jest.

In any case, that does not have to be a hard dependency. Users are free to pick their preferred bundling solution so the right thing to do here is remove it.

kofrasa added a commit that referenced this issue Jul 11, 2020
kofrasa added a commit that referenced this issue Jul 16, 2020
Also removed makefile and use explicit import path to functions
@kofrasa
Copy link
Owner

kofrasa commented Jul 16, 2020

Fix in latest version. esm module removed.

➜  mingo-error git:(master) ✗ node_modules/jest/bin/jest.js
 PASS  src/query.test.ts
  ✓ works (3 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        2.831 s, estimated 3 s
Ran all test suites.
➜  mingo-error git:(master) ✗

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

2 participants