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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix memory leak #10162

Merged
merged 2 commits into from
May 26, 2021
Merged

test: fix memory leak #10162

merged 2 commits into from
May 26, 2021

Conversation

viceice
Copy link
Member

@viceice viceice commented May 26, 2021

Changes:

Fix a huge memory leak in jest. It seems global nock usage caused it. Also refactord a litle bit to reduce more leaks.
This fix reduced the node heap usage with 8 worker down from ~700MB to ~200MB. 馃帀
Also test time went down from ~90s to ~80s.

Context:

Extracted from #10160, ref #10159

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added unit tests, or
  • No new tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

jest.mock('../lib/platform', () => ({
platform: jest.createMockFromModule('../lib/platform/github'),
initPlatform: jest.fn(),
getPlatformList: jest.fn(),
}));
jest.mock('../lib/logger');

beforeAll(() => {
nock.disableNetConnect();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the idea of this was to block all external connections?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but it caused the memory issues, see https://github.com/nock/nock#memory-issues-with-jest

@viceice viceice merged commit 48bfb1c into main May 26, 2021
@viceice viceice deleted the test/jest-leaks branch May 26, 2021 08:47
@renovate-release
Copy link
Collaborator

馃帀 This PR is included in version 25.31.4 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

@viceice viceice mentioned this pull request May 26, 2021
6 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants