-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Upgrading Jest to v29 and optimizing default configuration #26041
Conversation
ReactSuspenseWithNoopRenderer-test.js caused OOM when running this test file, and after analysis, I found that these two tests are the cause of the OOM problem, More specific reasons are under further debugging analysis
|
The most fundamental reason is that after the react/packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js Line 2431 in 0652bdb
jest needs to print the diff information,it will perform a recursive traversal and after executing deepCyclicCopyReplaceable(replacedReceived) it enters the recursive loop, because the array element passed into expect contains the fiber property The WeakMap in deepCyclicCopyReplaceable takes up a lot of memory until it triggers OOM. The main branch code does not have this problem because the testRunner uses jasmine, an exception is thrown after executing deepCyclicCopyReplaceable(replacedReceived), the test case itself is expecting a failed result and just happens to get the passed result (but is this the expected behavior? @acdlite ). After analyzing the call stack, I found that when the testRunner is jasmine, the recursive path is some fiber node -> baseState -> cache -> controller -> Symbol(impl) -> signal -> _globalObject -> jasmine -> process - > mainModule -> some module, then it generates an exception error After migrating from jasmine to circus there is no more jasmine property, it no longer generates an exception error but enters a long recursive loop until OOM. |
@@ -2428,17 +2440,21 @@ describe('ReactSuspenseWithNoopRenderer', () => { | |||
'Loading B...', | |||
]); | |||
// Still suspended. | |||
expect(ReactNoop.getChildren()).toEqual([span('A')]); | |||
expect(removeNonEnumerableProperties(ReactNoop.getChildren())).toEqual([ |
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.
Optimization reduced test time from a long time to 9 seconds.
Comparing: 6b30832...d67200b Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
e21ad14
to
4a24a3c
Compare
🟢 🥳 |
Looks like CI is failing |
e81c040
to
b57a6c7
Compare
@gaearon Because No cache is found, occasionally encountered, but it is not clear why |
Summary
I am preparing to split into smaller separate pr's to make review and merge easier, look #26088
How did you test this change?
ci green