ant-design: After upgrading from version 5.5 to version 5.16 I get Node memory limit error
Reproduction link
Not possible to provide such, and please do not autoclose this is a serious issue 3 of them were closed, peoples are having problems
Steps to reproduce
Upgrade to version 5.16.0
And then try to run a simple script like to check the TS types tsc --noEmit --pretty --p .
It fails because of this error
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
A library like antd should not each this much memory and something new was added in these last versions which just eats the memory as crazy, this is not normal at all
What is expected?
Is expected to not eat that much memory I saw a similar issue opened in the repo but people are suggesting to increasing memory that’s crazy a UI library should not eat 2gb of default memory that’s insane, I saw that someone gets the error even on start I mean it happens in existent projects that’s why is hard to provide a reproducible link, no one is going to provide a existent project as a reproducible
What is actually happening?
It just eats all the memory on types checks something was added in these versions which eats all the memory
| Environment | Info |
|---|---|
| antd | 5.16.0 |
| React | any |
| System | any |
| Browser | any |
nop
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 50 (24 by maintainers)
Had the same issue with the latest version 5.18.0 (TypeScript
5.4.5) and found out that this is caused byrc-field-formandrc-tableand the following typeDeepNamePath:https://github.com/react-component/table/blob/dc8807f6f2f77b24b3b7577853e06c003c67d9b0/src/namePathType.ts#L8-L34 https://github.com/react-component/field-form/blob/6fac7ed93719dc4b9885de3010728a1c11818664/src/namePathType.ts#L6-L32
Attention: This issue does not happen for all projects, but larger ones with a lot of
Form.ItemandTablecomponents!When running in my large project with
tsc --noEmit --extendedDiagnostics:When applying the optimized, below patch (e.g. with
patch-packageorpnpm patch):This is a difference of 3.4 GB vs 500 MB (!).
Patched
DeepNamePath(idk if this is optimal but it works for all my cases):When can we expect version
5.21.0to be released. @yoyo837I will test locally and change the length to 3. That’s it. Wait for this https://github.com/react-component/table/pull/1170 Release the version, then antd will release the version
表嵌入层级比较多时, 5.22.2构建时还是会轻松爆栈
I feel like it’s caused by adding type constraints to Table dataIndex because Table triggers multiple times
I cloned rc-table(with your changes) and tested locally with this issue repo and with our actual project. It seems to run successfully now.🥳 Thanks a ton. 🎉 Awaiting the release @crazyair
Hey @crazyair,
Are there any other examples where types are becoming
too largeforTypescriptto handle? I would like to see some examples to completely understand what’s really happening here. Or any official documentation fromTSthat mentions this limitation / caveat.Maybe we can solve this then.
If not, we should come up with an official type size limit to tell the developers of this library.
N size of depthness max, orN properties maximum for a single interface. Something like this, maybe?And thanks for working on Ant Design.
I made a repository that reproduces the bug https://github.com/11bit/antd-bug-reproduction.
This is standard vite react project + fairly complex TS types generated from Github’s graphql API. Bug happens because of this file. Some more info in the project’s readme.
By the way, as a workaround we narrow types that we use in table component. It is not very ergonomic but helps:
<— Last few GCs —>
[36668:000001D974841260] 106270 ms: Mark-sweep 2045.2 (2053.6) -> 2043.3 (2052.4) MB, 2037.9 / 0.0 ms (average mu = 0.067, current mu = 0.006) allocation failure scavenge might not succeed
<— JS stacktrace —>
==== JS stack trace =========================================
Security context: 0x02fd8fe808d1 <JSObject> 3: getUnionTypeFromSortedList(aka getUnionTypeFromSortedList) [000001296B484F89] [C:\Users\emre.durmusoglu\Desktop\enocta.eep\enocta.eep.react\node_modules\typescript\lib\typescript.js:~62688] [pc=00000115D3FCB651](this=0x01b4e1 4804b1 <undefined>,0x01963e604661 <JSArray[464…
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF718AA538F napi_wrap+114751 2: 00007FF718A4FE26 v8::base::CPU::has_sse+66646 3: 00007FF718A50C26 v8::base::CPU::has_sse+70230 4: 00007FF719265B3E v8::Isolate::ReportExternalAllocationLimitReached+94 5: 00007FF71924DC11 v8::SharedArrayBuffer::Externalize+833 6: 00007FF719119E7C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1436 7: 00007FF7191250B0 v8::internal::Heap::ProtectUnprotectedMemoryChunks+1312 8: 00007FF719121BD4 v8::internal::Heap::PageFlagsAreConsistent+3204 9: 00007FF7191173D3 v8::internal::Heap::CollectGarbage+1283 10: 00007FF719115A44 v8::internal::Heap::AddRetainedMap+2452 11: 00007FF719136D8D v8::internal::Factory::NewFillerObject+61 12: 00007FF718E9CED1 v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+1665 13: 00007FF7196BA09D v8::internal::SetupIsolateDelegate::SetupHeap+546637 14: 00007FF7196BAFCD v8::internal::SetupIsolateDelegate::SetupHeap+550525 15: 00007FF7196FC1B2 v8::internal::SetupIsolateDelegate::SetupHeap+817250 16: 00000115D3FCB651
try antd 5.15.4 + rc-table 7.44.0