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

Workaround a node >=12.5.0 bug that causes the process not to exit after tests have completed and cancerous memory growth #8787

Merged
merged 3 commits into from Aug 16, 2019

Commits on Aug 6, 2019

  1. workaround node >=12.5.0 issue

    This is a workaround for an issue that occurs in node 12.5.0 and newer, described in detail here:  nodejs/node#29001
    
    The behavior of the code in question is the same, however the change is enough to prevent locking the process into a "cancerous" state of memory growth.
    
    This is one of the weirdest bugs I've ever debugged.
    
    Under certain circumstances, Node process (starting from version 12.5.0, previous versions not affected), would not exit (even if we call `process.exit()` at the end of the file), and instead start to consume memory until it fills the whole available memory, using 100% CPU while at it.
    
    Here's a reproduction based on the `HasteMap`:
    
    https://gist.github.com/niieani/a527e9b2e6caf28e3021a50b938e4a91
    
    Standard memory or CPU profiling doesn't show anything (literally, there are no function calls shown in the profiler). Dumping the heap snapshot results in a 36MB file, even when the memory consumption of the process is 10 GB.
    
    The backstory is that in our case [`jest`](https://github.com/facebook/jest) would not end AFTER all the tests have completed, and instead would start consuming huge amounts of memory (on CI, multiple processes from separate PRs would deplete the 128GB of RAM on the machine) so I started going down the rabbit hole to try and pinpoint what is the cause of the issue, which lead me to this minimal reproduction scenario, but also to discover all the quirks that helped to avoid triggering the scenario.
    niieani committed Aug 6, 2019
    Copy the full SHA
    b552286 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    4ffdcd8 View commit details
    Browse the repository at this point in the history

Commits on Aug 16, 2019

  1. Update CHANGELOG.md

    scotthovestadt committed Aug 16, 2019
    Copy the full SHA
    2cad529 View commit details
    Browse the repository at this point in the history