-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
TSC Regression causing crash (Heap OOM) between version 4.8.4 & 4.9.3 in large project #53087
Comments
FYI: You can try https://github.com/microsoft/TypeScript/wiki/Performance-Tracing, it helped us locate the problem in #50515. |
I will attempt this as soon as i have recruited someone with enough ram to run it without crashing :) |
i had a quite similar issue recently after upgrading typescript. i can't remember the details, but it seems the problem was that under some circumstances tsc started creating a lot of types internally when asked to infer the type of a (typewise) complicated function. in the end, writing |
Ran into this issue myself today on a large project. |
Similar regression on 5.0.2. For me, 4.8.3 is ok. thanks for the exceptional bug report @whitespine! |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I was able to solve the OOM issue for myself with NODE_OPTIONS=--max-old-space-size=8192 tsc |
Since @Raynos solution is really just a stop gap. What is needed to further this ticket. We also have a large project that works fine on |
Here is what I have gathered from running some test.
Here is 4.9
From looking into the trace. It seems to be stuck in a loop related to the This is basically the part that loops (if I followed the trace right) import type { Namespace, TFuncKey } from 'i18next';
import { i18n } from './i18n';
export interface I18nText<N extends Namespace = Namespace> {
namespace: N;
keyName: TFuncKey<N>; // <-- TFuncKey seems to be the culprit
} That lib is for sure complicated typewise. But it worked as it should in 4.8 and breaks compilation in 4.9 and 5.0 Anything else I can provide? @jakebailey |
We've made some improvements recently that feel like this issue; can you try the nightly build? |
Using Version Running Result
|
Uh, hm, well, it's certainly not supposed to crash anymore. If you have the time, if you can roll it back by date to find when it started crashing, that would be helpful. |
Phew! Ok finally I got it. Last version that did not crash. Note that they were still very slow. And still needed NODE_OPTIONS=--max-old-space-size=8192` set.
/home/jarek/Development/project/node_modules/typescript/lib/tsc.js:113758
throw e;
^
RangeError: Value undefined out of range for undefined options property undefined
at Map.set (<anonymous>)
at getIndexedAccessTypeOrUndefined (/home/jarek/Development/project/node_modules/typescript/lib/tsc.js:56795:28)
at getIndexedAccessType (/home/jarek/Development/project/node_modules/typescript/lib/tsc.js:56764:12)
at /home/jarek/Development/project/node_modules/typescript/lib/tsc.js:56687:68
at map (/home/jarek/Development/project/node_modules/typescript/lib/tsc.js:209:19)
at distributeIndexOverObjectType (/home/jarek/Development/project/node_modules/typescript/lib/tsc.js:56687:21)
at getSimplifiedIndexedAccessType (/home/jarek/Development/project/node_modules/typescript/lib/tsc.js:56710:37)
at getSimplifiedType (/home/jarek/Development/project/node_modules/typescript/lib/tsc.js:56683:55)
at getNormalizedType (/home/jarek/Development/project/node_modules/typescript/lib/tsc.js:58949:481)
at isRelatedTo (/home/jarek/Development/project/node_modules/typescript/lib/tsc.js:59262:23) |
Oh, yikes, those are the versions before and after the module transform (where things were temporarily broken). Is your project somewhere that I can test it? |
It is not. Tomorrow I can perhaps try and create a repo that replicates some of the i18next stuff we are doing with types and see if I can get it to have the same issue. |
@jakebailey Well hey it wasn't that bad, I was able to replicate it with little code https://github.com/JarekToro/TSC-Regression-test-5.0 I understand this to be the offending line. If you remove that line. Or remove the function in its entirety. It builds correctly. Running |
I'm trying to look at this, but it seems like this thread contains many different OOMs and claims about which versions do and don't work. The only repro I have is @JarekToro's, but that explicitly says that something changed in 5.0. But, if I go back to TS 4.8, that code fails to compile entirely, saying that it's excessively deep. 4.9 hangs, as does 5.0. Is it supposed to complete? But, that's still not the original reported issue. I guess what I should be checking is https://github.com/Eranziel/foundryvtt-lancer/tree/oom? |
Testing the case from the original issue, a bisect points to #51151. @weswigham |
Reverting the above also fixes @JarekToro's case, so at least it seems like all of the cases in this thread with repros are the same thing. |
My OOM complaint is not a regression per se, just an artifact of a large codebase, I had multiple different versions & copies of the entire I don't have a reproduction example at hand, but |
@jakebailey That's good to hear, So yes in regards to my reproduction I was trying to focus on what version the build failed at. Which while related is technically different. Then the original issue. And while I simplified the code base to reproduce the crash. I didn't check to see if it passed on 4.8.4. If I have time I will try to make a separate repro of the slow down difference. |
Yeah, that might just be a different issue. We've had similar problems on DefinitelyTyped regarding that. If you can see something change between two different TS versions in the |
Have same issue with |
facing the same problem when upgrading to TS 5+ our tsc build slowly grows its memory usage until it eventually crashes with @whitespine 's error |
This comment was marked as off-topic.
This comment was marked as off-topic.
This issue explicitly says something broke between 4.8 and 4.9. If you have a problem going from 5.0 to 5.1, it is almost assuredly another issue and I would suggest filing a new one or looking for another recent issue about your problem which mentions 5.1. |
Updated from |
@ernestostifano As above, this issue is intended to be for a specific regression between 4.8 and 4.9; if you're jumping from 4.9 to 5.1, it's unlikely to be the same thing. Can you please file a new issue and also test 5.0 to better narrow the range? |
This comment was marked as spam.
This comment was marked as spam.
We cannot possibly keep track of things if all OOM errors are being dumped into one thread. It's much easier for us to track and ensure all of these problems are fixed when they are split into multiple issues with supporting reproductions. We'll dedupe them if they are the same. |
You have a point. Going to watch #54517 from now on, even though the error is the same. |
@jakebailey but there are several comments in this thread referring to versions above The build just take forever until it crashes going OOM. We downgraded to There is a comment from @JarekToro above reporting that the first affected version is Since ours is a very sensitive project, we will just have to downgrade to |
@jakebailey I understand your point and me too will watch #54517 instead, but it really looks like we are talking about the same issue here. |
OK, created a separate issue: #54542 |
For everyone that are struggling with Previous:
New:
However, now I've been bombarded with a lot of type errors 😄 |
@ashylen unfortunately the latest versions of i18next didn't resolve the issue for me. See reproducible example here i18next/i18next#1921 (comment) |
Still getting this issue. I'm getting the following error:
when running
|
Typescript compiler |
This thread has lots and lots of people with likely different issues; I've recently published a tool which makes it easy to bisect issues in TypeScript without knowing how to build TypeScript itself: https://www.npmjs.com/package/every-ts#bisecting It'd be extremely helpful for those who know which versions do and don't work to use this tool to identify which change in particular broke things; doing so will allow us to categorize these issues. |
We have the same issue as original and it is also with |
Do you have a repo that can be cloned and tested consistently? |
Hi, I didn't manage to create a repo reproducing the error but I have found a fix for the issue in i18next, I will report back there with a PR in 2-3 weeks if everything has worked as expected in the meantime, and link it here so that you can analyse wether it's something ts could get better at. |
In the meantime here is what seems to do the trick, in case someone wants to have a look i18next/i18next@master...GreenGoTech:i18next:master |
Signed-off-by: Avior <github@avior.me>
doing this helped me trace the actual problem. I had some recursive types in my code that were causing this issue. |
Bug Report
When updating typescript within our project from version 4.7.3 to a more recent version, our project began experiencing OOM issues.
Specifically, it is completely unable to build via
tsc
or eventsc --noEmit
.Ours is a somewhat large project, so I couldn't point to a minimal reproduction (sorry!).
I have 16GB of RAM so I doubt its a "classic" memory error, seems more likely something started infinitely using memory during a version upgrade.
🔎 Search Terms
tsc 4.9 4.9.5 Out of Memory Heap Out of Memory Crash Killed Silent Error
(Am i doing this right?)
🕗 Version & Regression Information
Error began occuring when updating from typescript 4.7.3 to any 4.9.3^ version.
Issue persists into Version 5.1.0-dev.20230303 (nightly at time of testing).
Issue is NOT present in v4.8.4, or any prior version we tried (that satisfied our dependencies, anyways.)
💻 Code
Branch state is: https://github.com/Eranziel/foundryvtt-lancer/tree/oom
Was unable to produce a minimally viable reproduction, as the OOM error gives next to no context as to where the issue occurs or why. Sorry. More than willing to provide more investigative information, but I don't really know what there is to provide.
🙁 Actual behavior
It crashes on more recent versions for no clear reason.
🙂 Expected behavior
I'd rather it didn't.
The text was updated successfully, but these errors were encountered: