{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/jest/issues/6399","repository_url":"https://api.github.com/repos/facebook/jest","labels_url":"https://api.github.com/repos/facebook/jest/issues/6399/labels{/name}","comments_url":"https://api.github.com/repos/facebook/jest/issues/6399/comments","events_url":"https://api.github.com/repos/facebook/jest/issues/6399/events","html_url":"https://github.com/facebook/jest/issues/6399","id":329370641,"node_id":"MDU6SXNzdWUzMjkzNzA2NDE=","number":6399,"title":"Jest memory problems in node environment","user":{"login":"mrrinot","id":22248411,"node_id":"MDQ6VXNlcjIyMjQ4NDEx","avatar_url":"https://avatars0.githubusercontent.com/u/22248411?v=4","gravatar_id":"","url":"https://api.github.com/users/mrrinot","html_url":"https://github.com/mrrinot","followers_url":"https://api.github.com/users/mrrinot/followers","following_url":"https://api.github.com/users/mrrinot/following{/other_user}","gists_url":"https://api.github.com/users/mrrinot/gists{/gist_id}","starred_url":"https://api.github.com/users/mrrinot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrrinot/subscriptions","organizations_url":"https://api.github.com/users/mrrinot/orgs","repos_url":"https://api.github.com/users/mrrinot/repos","events_url":"https://api.github.com/users/mrrinot/events{/privacy}","received_events_url":"https://api.github.com/users/mrrinot/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-06-05T09:21:12Z","updated_at":"2018-06-05T10:41:08Z","closed_at":null,"author_association":"NONE","body":"## 💬 Questions and Help\r\nStack:\r\n```\r\n  System:\r\n    OS: macOS High Sierra 10.13.4\r\n    CPU: x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz\r\n  Binaries:\r\n    Node: 8.1.4 - ~/.nvm/versions/node/v8.1.4/bin/node\r\n    npm: 6.0.0 - ~/.nvm/versions/node/v8.1.4/bin/npm\r\n  npmPackages:\r\n    jest: ^23.0.1 => 23.0.1\r\n    sequelize: ^4.37.10\r\n    pg: ^7.4.3\r\n    koa: ^2.3.0\r\n    babel-jest: ^22.4.3\r\n```\r\n## 1. Preface\r\nWe recently switched all our API's test from Mocha to Jest.\r\nWe have around 90 tests, half of them require to run synchronously due to them using our testing database (running seeds between them), so we have to use --runInBand.  \r\n\r\nI unfortunately can't share my code as it is private.  \r\n\r\n## 2. The problem\r\nRunning tests one by one was fine, I then tried to run all of them at once and things went bad.\r\nWith the --logHeapUsage, it seems context memory isn't GC'd resulting in a Javascript heap out of memory.\r\n\r\nI tried using the new option --detectOpenHandles to see what could prevent the GC to work but this is what came out:\r\n```\r\n  ●  PROMISE\r\n          at Promise.catch (<anonymous>)\r\n      at node_modules/core-js/library/modules/es6.promise.js:244:30\r\n      at Object.<anonymous>.module.exports (node_modules/core-js/library/modules/_iter-detect.js:19:5)\r\n      at Object.<anonymous> (node_modules/core-js/library/modules/es6.promise.js:243:74)\r\n      at Object.<anonymous> (node_modules/core-js/library/fn/promise.js:4:1)\r\n```\r\nI have around 6-8 of these, and no clue whatsoever of where to look.\r\n\r\nI searched around and found out it was most likely the database connection so I added these as a global teardown:\r\n```js\r\nafterAll(async () => {\r\n    await db.close(); // Sequelize instance\r\n    server.close(); // Koa server instance used with supertest (when needed)\r\n});\r\n```\r\n\r\nThis didn't change much, memory still goes up very quickly (30-40 MB per test).\r\nIn the end, I wrote a small file launching jest multiple times to avoid memory problems and stitching coverage report together but this isn't ideal.\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/jest/issues/comments/394663612","html_url":"https://github.com/facebook/jest/issues/6399#issuecomment-394663612","issue_url":"https://api.github.com/repos/facebook/jest/issues/6399","id":394663612,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDY2MzYxMg==","user":{"login":"SimenB","id":1404810,"node_id":"MDQ6VXNlcjE0MDQ4MTA=","avatar_url":"https://avatars1.githubusercontent.com/u/1404810?v=4","gravatar_id":"","url":"https://api.github.com/users/SimenB","html_url":"https://github.com/SimenB","followers_url":"https://api.github.com/users/SimenB/followers","following_url":"https://api.github.com/users/SimenB/following{/other_user}","gists_url":"https://api.github.com/users/SimenB/gists{/gist_id}","starred_url":"https://api.github.com/users/SimenB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SimenB/subscriptions","organizations_url":"https://api.github.com/users/SimenB/orgs","repos_url":"https://api.github.com/users/SimenB/repos","events_url":"https://api.github.com/users/SimenB/events{/privacy}","received_events_url":"https://api.github.com/users/SimenB/received_events","type":"User","site_admin":false},"created_at":"2018-06-05T10:41:07Z","updated_at":"2018-06-05T10:41:07Z","author_association":"COLLABORATOR","body":"Sure, but a reduced case would help. As is this report isn't actionable for us"}}
{"actor":{"display_login":"SimenB"}}