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 when running with Jest #1966

Closed
4 of 8 tasks
kirillgroshkov opened this issue Mar 30, 2019 · 5 comments
Closed
4 of 8 tasks

Memory leak when running with Jest #1966

kirillgroshkov opened this issue Mar 30, 2019 · 5 comments

Comments

@kirillgroshkov
Copy link

kirillgroshkov commented Mar 30, 2019

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

4.6.6

Description

We use @sentry/node in our unit tests with Jest.

We discovered that just importing @sentry/node (as const Sentry = require('@sentry/node')) leaks memory when running in Jest tests.

I've created a minimal repro here to showcase the issue: https://github.com/kirillgroshkov/sentry-jest-leak-repro

Good to note that Jest has memory leak issues with many libraries, not just this one. Some popular libraries, e.g graceful-fs were "fixed" to not leak memory with Jest (given that Jest itself is also a "popular library", number 1 in "StateOfJS 2018" to be precise).

There's a symmetric issue opened in Jest repo, cause I'm expecting some back-and-forth between this repo and Jest: jestjs/jest#8248

Why this issue is important - it blocks us to run our test suite in our CI environment (CircleCI), which has 4Gb memory constraint. It runs out-of-memory already with ~150 test files that we have in our project. See steps to reproduce further.

Some related issues in Jest:
jestjs/jest#8248
jestjs/jest#6814
jestjs/jest#6738
jestjs/jest#7311
jestjs/jest#6399

@xueyongg
Copy link

any updates on this issue?

@kirillgroshkov
Copy link
Author

kirillgroshkov commented Aug 29, 2019

I noticed it was getting worse in recent versions of Sentry. Still a blocker for us to update, so we're on older version now.

@kamilogorek
Copy link
Contributor

I noticed it was getting worse in recent versions of Sentry.

@xueyongg @kirillgroshkov it has been fixed over 3 months ago in version 5.4.2.

https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#542

[node] fix: Force agent-base to be at version 4.3.0 to fix various issues. Fix #1762, fix #2085

Old heap usage: https://gist.github.com/kamilogorek/c3d8e10287d31c91182dafd42af197f2#file-log_leaking_4-6-6-txt
New heap usage: https://gist.github.com/kamilogorek/c3d8e10287d31c91182dafd42af197f2#file-log_leaking_5-6-2-txt

Cheers!

@kirillgroshkov
Copy link
Author

oh, great fix!

But we still see issues with memory in recent versions of Sentry. Issues are probably different, so my old reproduction repo doesn't cover them (or maybe we're doing something more complicated with Sentry that it leaks). When I have time - I'll try to create another repro to highlight new issues.

But great work fixing the current issue!

@kamilogorek
Copy link
Contributor

It'd be greatly appreciated @kirillgroshkov :)

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