-
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 crash with node OOM #30050
Comments
This comment has been minimized.
This comment has been minimized.
Seeing a similar issue in our own codebase after upgrading to TypeScript v3.4.1. Here's the error that I get:
I'll try to see if I can narrow it down to a simple repro case. @RyanCavanaugh Do you have any suggestions for how I might go about debugging the issue? |
@jdhuntington the culprit seems to be this line in FocusZone.types.ts: /**
* FocusZone component props.
*/
export interface IFocusZoneProps
extends React.HTMLAttributes<HTMLElement | FocusZone> {
elementType?: keyof React.ReactHTML; // <- causing the crash
} I am continuing to investigate what is causing this. |
@rbuckton I can confirm that |
It seems to be a combination of |
I think I have discovered the simplest repro for your case: import * as React from "react";
declare const Tag: keyof React.ReactHTML;
<Tag ref={{}} /> I'm continuing to investigate, but my guess is that this is resulting in a significant number of instantiations due to the number of elements on |
Upgrading from tsc |
@matthewtebbs-codaio I think the most helpful thing would be narrowing it down to a simple repro case (like this one) so that it can be used to diagnose the problem. Do you know if you are seeing the same issue due to |
@maxdeviant will take a look. We use React so that's a possibility. |
For reference, here's the issue repro without involving react or jsx. (And a second version that doesn't rely on union call resolution in its construction) (And minimum size) When we normalize an intersection of unions, the resulting union of intersections has an exponential number of clauses - IMO, the most graceful general thing we could do would be refuse to normalize and work as best we can with the un-normalized intersection of unions. #31486 helps in cases where we don't actually use |
With #31572 we'll issue an error if a union type resulting from intersection type normalization exceeds 100,000 constituent types. The error will highlight the construct in which the excessively large type originates. This doesn't fix the potentially explosive types in |
So it’s essentially a combinatorial explosion of types? Yikes! |
Exactly exponential, actually. Conversion of formal logic into conjunctive normal form (which unions and intersections are analogous to) is well-known to be exponential in resulting clause count. |
@weswigham
So if my interpretation is correct, TS is going from CNF which is manageable ( ...that being said, I suppose if we were normalizing in the opposite direction we'd face the exact same problem sooner or later. |
Sure, the point is normalizing clausally produces an expontential number of clauses when you need to invert the nesting order. |
TypeScript Version: 3.4.0-dev.20190222
Search Terms: Crash, OOM, infinite
Code
Across a few files - self-contained repro at https://github.com/jdhuntington/tsc-repro
Expected behavior:
This is a trimmed down repro of an issue encountered in a larger project. It is not expected to compile successfully, but should print several error messages.
Actual behavior:
tsc
runs for several minutes comsuming 100%. Eventually the nodeprocess exits with this error:
Related Issues: #29597 , #29326
The text was updated successfully, but these errors were encountered: