Memory leak when running with Jest #376
Labels
api: datastore
Issues related to the googleapis/nodejs-datastore API.
priority: p2
Moderately-important priority. Fix may not be included in next release.
🚨
This issue needs some love.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
We use
@google-cloud/datastore
in our unit tests with Jest.We discovered that just importing
@google-cloud/datastore
(asconst { Datastore } = require('@google-cloud/datastore')
) leaks memory when running in Jest tests.I've created a minimal repro here to showcase the issue: https://github.com/kirillgroshkov/datastore-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).I will open and link a symmetric issue in Jest repo to track, cause I'm expecting some back-and-forth between this repo and Jest. (UPD: jestjs/jest#8247)
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#6814
jestjs/jest#6738
jestjs/jest#7311
jestjs/jest#6399
Environment details
@google-cloud/datastore
version: 3.1.2Steps to reproduce
Use minimal repro repository: https://github.com/kirillgroshkov/datastore-jest-leak-repro
Run
npm run test-leaking
ornpm run test-leaking-detectLeaks
to see the issue.The text was updated successfully, but these errors were encountered: