Skip to content
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

Out-of-memory compiling project that uses fp-ts 0.2.6+ and TS@next #16029

Closed
sandersn opened this issue May 23, 2017 · 11 comments
Closed

Out-of-memory compiling project that uses fp-ts 0.2.6+ and TS@next #16029

sandersn opened this issue May 23, 2017 · 11 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@sandersn
Copy link
Member

@OliverJAsh kindly provided a small repro:

This fixed the issue for https://github.com/OliverJAsh/ts-2.4-memory-issue, but I ran into another scenario where the memory issue pops up again. I've created a small test case in https://github.com/OliverJAsh/ts-2.4-memory-issue/tree/2.4.0-dev.20170519.

@sledorze additionally noted that the issue happens with ill-typed programs, not well-typed ones.

@OliverJAsh
Copy link
Contributor

Thanks for opening this!

@mhegazy mhegazy added the Bug A bug in TypeScript label May 23, 2017
@sledorze
Copy link

Thanks a lot!!!!

@OliverJAsh
Copy link
Contributor

@sandersn Do you have any tips about how to debug this in a TypeScript application? I'm currently blocked by it :-(

@OliverJAsh
Copy link
Contributor

I was able to fix the issue in my example project by deduping fp-ts so there was only one version, not two. The example uses 0.2.8 and 0.2.7. However this was not easy to find, so ideally tsc would tell me the error still.

@gillesfabre34
Copy link

Hello,
I have the same bug in this situation :

In a first component, I have a field like this :

this.foreignFields = [{objectType: 'Region'}, {objectType: 'Item'}];

This component extends an abstract class where the type of this.foreignFields is defined like this :

foreignFields: [{objectType:any}];

In this configuration, I can have two kinds of problems :

  • very long time to compile
  • a bug during compilation with this message :

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

But if I remove one object from my array, like this :

this.foreignFields = [{objectType: 'Region'}];

there is no bug.

I can "fix" this bug with two other ways :

  • Instead of writing in abstract class

foreignFields: [{objectType:any}];

I write

foreignFields: any;

  • Instead of declaring type in abstract class, I declare it inside my concrete component

Hope it will helps.

@gillesfabre34
Copy link

Other "solution" :

Instead of declaring type in my abstract class like this :

foreignFields: [{objectType:any}];

I do :

foreignFields: ForeignFields;

and I declare my new type ForeignFields :

export type ForeignFields = [{objectType: any}];

@sandersn
Copy link
Member Author

@gillesfabre34 are you using fp-ts as well? Or is your repro standalone?

I think you also meant to have foreignFields: { objectType: any }[]. Infix brackets means a unary one-element tuple in TypeScript. Postfix brackets means array.

If that is correct, hopefully that is an even better workaround.

@gillesfabre34
Copy link

No, I don't use fp-ts, but I had the same error message with my own webapp.

I searched help on Google and I found your issue which seems to be the same than mine, but maybe not. So I thought it could help you to see another situation with the same problem.

About using Array or Tuple, in fact I wanted to have an array where each element was of type {objectType: any}. But maybe that I needed to declare at first my type ForeignFields = [{objectType: any}]. In fact, maybe that typescript didn't really understand that I was using my own type in my array.

Changing foreignFields: [{objectType:any}] by foreignFields: { objectType: any }[] solved the problem as well as exporting a new type ForeignFields = [{objectType: any}];, so thanks for your help.

I hope that my bug will help you to solve yours ...

@OliverJAsh
Copy link
Contributor

I have a project that has no compile errors and all dependencies share the same version of fp-ts. If I try updating one of these dependencies to use a different fp-ts version, the memory issue reappears. Perhaps there are compile errors from the upgrade being masked by the memory issue.

@OliverJAsh
Copy link
Contributor

I can also confirm this error still occurs with TypeScript 2.4.2.

@sandersn
Copy link
Member Author

#17984 fixes this. It finishes in 2.3 seconds after #17984, 4.2 seconds on 2.3 and crashes out-of-memory before #17984.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Aug 23, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

6 participants