-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
feat: add workerIdleMemoryLimit to support worker recycling in the event of node >16.11.0 memory leaks #13056
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
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
3e4c26b
feat: process recycling
phawxby 833e429
chore: changelog
phawxby 7da8127
chore: remove temp files
phawxby 40a23cf
test: more complete functional testing
phawxby 1961d65
docs: update docs for PR review
phawxby d7f292f
chore: try this test config
phawxby 8bfcd74
chore: linting
phawxby fd1be6f
feat: add improved error checking and promise handling
phawxby 233477e
chore: add facebook header
phawxby 19fb71c
fix: use os spy rather than mock to retain platform functions
phawxby e2a853d
fix: spying of totalmem
phawxby ab6554d
chore: add some logging to help debugging
phawxby 207ae05
chore: more debugging
phawxby c4d2389
chore: more debugging
phawxby 0f5c7bb
chore: check files exist
phawxby d35e4b9
chore: try as a specific js import
phawxby daee499
chore: try this
phawxby fd96e78
chore: remove debugging and cleanup
phawxby 576ca63
chore: debug failing test
phawxby 491b16c
fix: windows tests
phawxby 479c123
chore: use verbose output to help
phawxby ad238f2
Merge branch 'process-recycling' of https://github.com/phawxby/jest i…
phawxby e3e63e4
chore: disable silent reporter
phawxby 74ce892
chore: temporary change to allow me to see where the tests are stalling
phawxby 8467b8b
chore: set sensible timeout
phawxby 6338419
chore: there's an argument for what i want to do
phawxby d2acdc3
chore: try this
phawxby dea2ef2
chore: remove now I have the test order
phawxby 44ff11d
chore: single thread to track down the failing test suite
phawxby 6b3ba00
chore: does skipping this test make the timeouts go away?
phawxby f208aa9
fix: fatal but not out of memory errors should retry
phawxby 1ca06bc
fix: out of memory test
phawxby c98dd32
chore: increase timeout
phawxby c21b48e
chore: debugging output
phawxby 33405a2
Merge branch 'process-recycling' of https://github.com/phawxby/jest i…
phawxby 98f5e82
chore: limit to just failing test and add logging
phawxby a1b647f
chore: more debugging
phawxby 54dccb3
feat: add stderr concat
phawxby 0f5da7d
chore: back to full tests
phawxby debf034
test: fix use simple count in case same pid comes up twice
phawxby 4619055
test: add retry and increase timeout
phawxby da47b50
test: more retries
phawxby ba00b26
chore: revert changes to jest config
phawxby 019c5d4
feat: port idle usage to thread workers
phawxby 7239650
chore: docs
phawxby fdb4a66
chore: linting
phawxby 3e3be99
feat: add shorthand idle limit parsing
phawxby 9f9dff1
docs: copyright header
phawxby 43f1054
chore: improve test flake
phawxby 791b7a5
chore: fix typing
phawxby f3db1cc
chore: pr feedback
phawxby File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
packages/jest-config/src/__tests__/stringToBytes.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| /** | ||
phawxby marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| import stringToBytes from '../stringToBytes'; | ||
|
|
||
| describe('numeric input', () => { | ||
| test('> 1 represents bytes', () => { | ||
| expect(stringToBytes(50.8)).toEqual(50); | ||
| }); | ||
|
|
||
| test('1.1 should be a 1', () => { | ||
| expect(stringToBytes(1.1, 54)).toEqual(1); | ||
| }); | ||
|
|
||
| test('< 1 represents a %', () => { | ||
| expect(stringToBytes(0.3, 51)).toEqual(15); | ||
| }); | ||
|
|
||
| test('should throw when no reference supplied', () => { | ||
| expect(() => stringToBytes(0.3)).toThrowError(); | ||
| }); | ||
|
|
||
| test('should throw on a bad input', () => { | ||
| expect(() => stringToBytes(-0.3, 51)).toThrowError(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('string input', () => { | ||
| describe('numeric passthrough', () => { | ||
| test('> 1 represents bytes', () => { | ||
| expect(stringToBytes('50.8')).toEqual(50); | ||
| }); | ||
|
|
||
| test('< 1 represents a %', () => { | ||
| expect(stringToBytes('0.3', 51)).toEqual(15); | ||
| }); | ||
|
|
||
| test('should throw when no reference supplied', () => { | ||
| expect(() => stringToBytes('0.3')).toThrowError(); | ||
| }); | ||
|
|
||
| test('should throw on a bad input', () => { | ||
| expect(() => stringToBytes('-0.3', 51)).toThrowError(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('parsing', () => { | ||
| test('0% should throw an error', () => { | ||
| expect(() => stringToBytes('0%', 51)).toThrowError(); | ||
| }); | ||
|
|
||
| test('30%', () => { | ||
| expect(stringToBytes('30%', 51)).toEqual(15); | ||
| }); | ||
|
|
||
| test('80%', () => { | ||
| expect(stringToBytes('80%', 51)).toEqual(40); | ||
| }); | ||
|
|
||
| test('100%', () => { | ||
| expect(stringToBytes('100%', 51)).toEqual(51); | ||
| }); | ||
|
|
||
| // The units caps is intentionally janky to test for forgiving string parsing. | ||
| describe('k', () => { | ||
| test('30k', () => { | ||
| expect(stringToBytes('30K')).toEqual(30000); | ||
| }); | ||
|
|
||
| test('30KB', () => { | ||
| expect(stringToBytes('30kB')).toEqual(30000); | ||
| }); | ||
|
|
||
| test('30KiB', () => { | ||
| expect(stringToBytes('30kIb')).toEqual(30720); | ||
| }); | ||
| }); | ||
|
|
||
| describe('m', () => { | ||
| test('30M', () => { | ||
| expect(stringToBytes('30M')).toEqual(30000000); | ||
| }); | ||
|
|
||
| test('30MB', () => { | ||
| expect(stringToBytes('30MB')).toEqual(30000000); | ||
| }); | ||
|
|
||
| test('30MiB', () => { | ||
| expect(stringToBytes('30MiB')).toEqual(31457280); | ||
| }); | ||
| }); | ||
|
|
||
| describe('g', () => { | ||
| test('30G', () => { | ||
| expect(stringToBytes('30G')).toEqual(30000000000); | ||
| }); | ||
|
|
||
| test('30GB', () => { | ||
| expect(stringToBytes('30gB')).toEqual(30000000000); | ||
| }); | ||
|
|
||
| test('30GiB', () => { | ||
| expect(stringToBytes('30GIB')).toEqual(32212254720); | ||
| }); | ||
| }); | ||
|
|
||
| test('unknown unit', () => { | ||
| expect(() => stringToBytes('50XX')).toThrowError(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| test('nesting', () => { | ||
| expect(stringToBytes(stringToBytes(stringToBytes('30%', 51)))).toEqual(15); | ||
| }); | ||
|
|
||
| test('null', () => { | ||
| expect(stringToBytes(null)).toEqual(null); | ||
| }); | ||
|
|
||
| test('undefined', () => { | ||
| expect(stringToBytes(undefined)).toEqual(undefined); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /** | ||
| * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| function stringToBytes( | ||
| input: undefined, | ||
| percentageReference?: number, | ||
| ): undefined; | ||
| function stringToBytes(input: null, percentageReference?: number): null; | ||
| function stringToBytes( | ||
| input: string | number, | ||
| percentageReference?: number, | ||
| ): number; | ||
|
|
||
| /** | ||
| * Converts a string representing an amount of memory to bytes. | ||
| * | ||
| * @param input The value to convert to bytes. | ||
| * @param percentageReference The reference value to use when a '%' value is supplied. | ||
| */ | ||
| function stringToBytes( | ||
| input: string | number | null | undefined, | ||
| percentageReference?: number, | ||
| ): number | null | undefined { | ||
| if (input === null || input === undefined) { | ||
| return input; | ||
| } | ||
|
|
||
| if (typeof input === 'string') { | ||
| if (isNaN(Number.parseFloat(input.slice(-1)))) { | ||
| // eslint-disable-next-line prefer-const | ||
| let [, numericString, trailingChars] = | ||
| input.match(/(.*?)([^0-9.-]+)$/i) || []; | ||
|
|
||
| if (trailingChars && numericString) { | ||
| const numericValue = Number.parseFloat(numericString); | ||
| trailingChars = trailingChars.toLowerCase(); | ||
|
|
||
| switch (trailingChars) { | ||
| case '%': | ||
| input = numericValue / 100; | ||
| break; | ||
| case 'kb': | ||
| case 'k': | ||
| return numericValue * 1000; | ||
| case 'kib': | ||
| return numericValue * 1024; | ||
| case 'mb': | ||
| case 'm': | ||
| return numericValue * 1000 * 1000; | ||
| case 'mib': | ||
| return numericValue * 1024 * 1024; | ||
| case 'gb': | ||
| case 'g': | ||
| return numericValue * 1000 * 1000 * 1000; | ||
| case 'gib': | ||
| return numericValue * 1024 * 1024 * 1024; | ||
| } | ||
| } | ||
|
|
||
| // It ends in some kind of char so we need to do some parsing | ||
| } else { | ||
| input = Number.parseFloat(input); | ||
| } | ||
| } | ||
|
|
||
| if (typeof input === 'number') { | ||
| if (input <= 1 && input > 0) { | ||
| if (percentageReference) { | ||
| return Math.floor(input * percentageReference); | ||
| } else { | ||
| throw new Error( | ||
| 'For a percentage based memory limit a percentageReference must be supplied', | ||
| ); | ||
| } | ||
| } else if (input > 1) { | ||
| return Math.floor(input); | ||
| } else { | ||
| throw new Error('Unexpected numerical input'); | ||
| } | ||
| } | ||
|
|
||
| throw new Error('Unexpected input'); | ||
| } | ||
|
|
||
| // https://github.com/import-js/eslint-plugin-import/issues/1590 | ||
| export default stringToBytes; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.