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
feat: add workerIdleMemoryLimit to support worker recycling in the event of node >16.11.0 memory leaks #13056
Conversation
I'm going to try and write some more tests for this so even if approved don't merge yet |
@@ -478,6 +480,7 @@ export type ProjectConfig = { | |||
transformIgnorePatterns: Array<string>; | |||
watchPathIgnorePatterns: Array<string>; | |||
unmockedModulePathPatterns?: Array<string>; | |||
workerIdleMemoryLimit?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be part of global config, not project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the case for both. You may want to set a sensible global default perhaps running on a machine with known memory usage limitations but then configure specifically for projects where you may use less threads and allow more memory. In all honesty I could go either way, if you want it removing I can remove it.
exciting! thanks for looking into it! |
@SimenB this should be better now. I've created edge case tests using actual workers (as opposed to mocked ones) to validate that they behave as expected. |
Are some of these tests expected to be failing? |
There is some flake, but the failures now seems to be the new tests? |
Some of them seem to be a dependency bug. chalk/supports-color#135 |
Actually I think I'm being dumb |
@SimenB do you have any good ideas why those 2 tests seem to be failing in CI? They work absolutely fine locally with the same commands. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new option is not supported in thread workers?
I hadn't planned on it but I actually don't think it would be too hard to port over. I'll take a quick crack at it |
Actually, do we even know if this is necessary? This is primarily to deal with a memory leak in process workers. As far as I know there's currently no way to enable worker threads in jest via a config/cli option. It may be completely unnecessary in threaded workers. |
There's not, but the same capability should be added to both types of workers. |
I think this PR is generally done, I'm just not really sure what to do to resolve the flaky tests. They seem to work more often than not, but I know that's still not ideal. Also the worker memory limit is specified in bytes, I wonder if that should be MB to make the number a bit easier to understand. |
We could do shorthand? Bytes if no unit, but support e.g. |
@SimenB done. I think I may have solved my flaky test problem too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! this looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
@SimenB what's the release process/cycle for Jest? |
Stable release next week |
Was trying this out this morning and ran into a config validation issue:
The Seems to me like |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
#11956 (comment)
Test plan
Numerous new test cases added except it's hard to test for the specific issue as the memory usage problem is extremely hard to replicate outside of very complicated applications
Ideally I would like to end-end test this but I have no idea how I would do that