-
Notifications
You must be signed in to change notification settings - Fork 34
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
JavaScript heap out of memory #34
Comments
Thanks for the report. Can you add a few details about how this is triggered:
|
It's as simple as
|
Hmm. I'm not having any luck repro-ing in newer versions, but I'll try with the exact Node/tsc versions to see if that would do it |
+1 I'm going through the same issue.
just import and use typing
Is there anything I can do to help for this issue? |
My guess is that it issue when many types(maybe over 10 types??) are import and used. It doesn't happen when you first use it, but it happens when you bring in a lot of types. |
@Eyas here's the
|
@Eyas btw, the resulting typings file for |
Yeah, I'll need to see how it could be broken up. The thing is, it's auto-generated and a lot of the fields in schema.org reference each other liberally, we'll need to figure out a neat abstraction boundary where splitting makes sense. |
Hm. Another theory is that it isn't the file being too large, but the import { Article } from "schema-dts";
type WithContext2<T extends {"@type": string}> = {
"@context": "https://schema.org",
} & T;
const article: WithContext2<Article> = {
...
}; performed differently. |
@Eyas We're getting the same issue even declaring our own |
I'd love ideas to fix this, if anyone has time to dig. The issue here is that breaking the file into smaller files isn't very possible without creating some loopy dependencies. Schema.org schema can be very circular, so finding the right way to break it up isn't immediately clear to me. |
@iflix-erwin what version of TS and node are you using? Have you tried upgrading? |
@zernie Node: 12.4.0, TS: 3.5.3 |
Well that's unfortunate. I think we gonna need some help from TS developers |
Chiming in with the same problem reported from our CI. I'm importing and using the following types: import { ItemList, ListItem, VideoObject, WithContext } from 'schema-dts'; |
Right now this is a blocking issue for me. I'm wondering if there's any way we can build a version of the file that only contains the types we require for our project. It's a little clunky but would be better than our tools just crashing. Is there a way to use
|
@download13 Interesting, I was going to suggest this, but it looks like Recipe.nt doesn't just contain Recipe and its properties, but also properties who have the range Recipe (i.e. https://schema.org/recipe). One way to fix this is to make sure that schema-dts-gen can ignore some properties. An You might still have issues here because Recipe.nt won't include definitions for the types of properties on Recipe, e.g. CreativeWork, MediaObject, Person, AlignmentObject, Thing, etc. That last one there, Thing, is particularly problematic, since it results in potentially any other type being included. (FWIW, Let me think about a schema-dts-gen approach to this. I imagine some combination of:
might work. But it would be kind of hard to get set up. |
v0.5.0 tries to trim down some excess stuff there. Removes some ~800 lines of declaraitons, and makes some types readonly that in theory could help. Those of you who have been blocked by this might want to try again. |
For me at least, the TS language server still won't return results to intellisense. It just keeps saying |
I'm having the same problem, the TS server just crashes if I load this library and builds will timeout |
Do you have any information on your environment to reproduce it? e.g. TS version, OS, is this running in a container, etc? Still haven't been able to repro this... |
Looks like this might've been fixed for us in typescript 3.9.0-beta |
Interesting! I think some of the type tightening around intersections dramatically reduces the number of different types TS needs to consider when evaluating |
Any updates? I seem to be experiencing similar issues where importing types from this package stops intellisense from working and causes build timeouts |
Can you try Typescript 3.9?
The current assumption is that this would be fixed by it
…On Tue, Apr 28, 2020, 9:11 AM Jason Gerbes ***@***.***> wrote:
Any updates?
I seem to be experiencing similar issues where importing types from this
package stops intellisense from working and causes build timeouts
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#34 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEHLOHPA2OAPRHMO4ULBJLRO3IYHANCNFSM4I32YGCA>
.
|
I was wrong. 3.9 definitely improved the performance, and it gets a lot farther before failing, but the language server still crashes |
@download13 @jasongerbes if you're using VS Code you might also want to try increasing memory for the TS Language Server, see microsoft/TypeScript#37214. |
Rather than inlining a "leaf" type as an intersection in a big union, name it. This should hopefully help with google#34. This is based on advice from @amcasey regarding compiler performance: > I've definitely seen some impressive perf improvements from naming > intermediate types (because it can short-circuit structural type > comparison, which is very expensive). This fits neatly with my initial description of the Schema.org type system here: https://blog.eyas.sh/2019/05/modeling-schema-org-schema-with-typescript-the-power-and-limitations-of-the-typescript-type-system/ There's still some room for improvements: - Some intermediate types are simply aliases, can we remove these? - 'DataType's don't necessarily fit neatly here.
I just pushed [email protected], I got some advice it might help. |
Hey @Eyas, I have just tested |
@jasongerbes do you mind letting me know your:
|
|
thanks, and one more thing: is this on your local machine or some CI environment? |
Both locally (Windows and macOS) and on our CI environment |
Does this reliably repro with a minimal repro as simple as the one @kkak10 mentioned in #34 (comment) ? If the there's a different minimal repro for this, can you share it? |
I've been having trouble with TypeDoc and up until today I was under the impression that typedoc was at fault, but after a lot of digging I reduced my failing docs build down to a small subset of components, they all had one thing in common, So I created a minimal repo to test against and found that I could easily reproduce the issue. My project was using TS: 3.9.7 Related TypeDoc issues: Minimal Example: I hope this helps. We're actually almost at the point of stripping schema-dts out of our project due to its size and rigidity, it'd be good to see it broken down into more versatile chunks. |
Thanks @nedkelly -- My first thought is that this should still be a TypeDoc issue. schema-dts has a very large type tree in part because it is trying to express a very and messy type system (schema.org). I got some help from the TS team to find a few ways to make the type tree more friendly to the TS compiler, and this will continue to be an area of work. But TypeDoc being able to traverse the existing type tree without OOM-ing probably also includes some optimizations/improvements on their own. Your minimal example is probably helpful for TypeDoc themselves. And if someone from TypeDoc looks into this and has suggestions on reducing the cost of the schema-dts type tree, I'm all ears. But they might also identify areas for improvement within TypeDoc. It might be helpful opening a separate issue against typedoc with your minimal example |
@Eyas I agree, TypeDoc should definitely be able to traverse large type trees, I'll open an issue with them and see what sort of feedback I can get. Opened here: TypeStrong/typedoc#1346 |
Hi all -- I managed to reproduce a related issue more reliably, and changes in 0.8.1 should address it. I'm not sure if it's enough per se, but I'm noticing notable improvements on my end. |
This hasn't come up for the past few years. TS changes + typing simplifications have likely mitigated this over the long term. Let's file a new issue if something along these lines comes up for people in modern stacks. |
I'm getting a
JavaScript heap out of memory
error when trying to runtsc --noEmit
.Node version: v10.16.0
TypeScript: 3.4.3
ts-loader: 5.4.5
ts-node: 8.1.0
I guess the problem can be fixed by upgrading the dependencies to the latest versions and increasing
max-old-space-size
, but that's unfortunately not possible yet in my current project :(The text was updated successfully, but these errors were encountered: