You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TS v2.3.1 runs out of memory compiling FP library #15443
Here's another repro which involves other modules.
Worth noting that with the following example the code completion feature in VSCode with TypeScript v2.2.2 hangs with CPU 100%
import*asarrayfrom'fp-ts/lib/Array'import*asvalidationfrom'fp-ts/lib/Validation'exportfunctionpouet(xs: number[],f: (x: number)=>validation.Validation<string[],number>): void{constx=array.traverse(validation..getStaticApplicative(array))(f,xs)// Long hanging due to this space}
In the Array.ts module, if I remove the currying in the definition of traverse, i.e from
changed the title [-]FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory (TS v2.3.1)[/-][+]TS v2.3.1 runs out of memory compiling FP library[/+]on May 1, 2017
I can't repro that exact behaviour in VS Code. For me, initial load time is very long and then if I type a dot after validation I get completions one time. Afterwards I just get Loading... indicating that the language service is not responsive. Does VSCode itself become unresponsive for you?
Are you using "typescript.tsdk" to point to typescript@next? Here's my settings.json
For me, initial load time is very long and then if I type a dot after validation I get completions one time. Afterwards I just get Loading... indicating that the language service is not responsive
Stéphane Le Dorze (@sledorze) the inference-too-deep cap isn't configurable right now. Setting it too low will start to create bogus inferences of {}. Maybe we should revisit the value, but I don't think it should be configurable. The only time you need it, you're avoiding an architectural problem of the compiler.
Node crashes don't give much of the stack, as you can see. I debugged using the following:
Then I opened Chrome to the provided URL and let the compiler run for a while. Each time I did this there were many recursive calls in inference on the stack, so I guessed that inference was causing the out-of-memory crash. (You can substitute any copy of tsc.js that you have, you don't need to build a copy yourself.)
Update from talking to Anders Hejlsberg (@ahejlsberg). The inference-too-deep cap should maybe be removed entirely — it was a mistake from when we believed that inference should behave similarly to assignability checking.
Anders Hejlsberg (@ahejlsberg) is working on a fix that just quits when inference sees an instantiation of a type that it has seen before. That should fix this bug.
I'll also add fp-ts to our real-world code test suite after the bug is fixed so that we can catch compiler bugs in this library and similar FP/monad libraries.
Reacted by Daniel Rosenwasser, Giulio Canti, Oliver Joseph Ash, Rizky Luthfianto and Herrington Darkholme
Nathan Shively-Sanders (@sandersn) note that the problem happens with fp-ts when there's a type error in the program, not compiling an actually well typed program (this is from my observations).
Also considering this problem, the worst case is not when one changes some code and have the compiler getting lost in inference, the real issue is when one upgrade a library and it breaks the compiler without any clue where the type error is and how to fix it.
I'm keeping this bug closed just to make bookkeeping simpler. And it's unlikely that the compiler is getting stuck in inference again (or at least, for the same reason).
I'm not sure whether or not the pain point I had today was caused by this issue, but I also was running into the problem of Node running out of space on the heap.
I reverted to 2.3.2, and was able to successfully compile. If you guys can nail down this bug, it would be greatly appreciated!
Bryan Rayner (@bryanerayner) there are, unfortunately, many reasons for typescript to run out of memory while compiling fp-ts. The root cause of this issue is definitely fixed: type inference no longer recursively examines types that it has already seen. But (for example) assignability checking still does recursively examine types. It's likely that the issue you're hitting is different. Can you open a new issue and give some detail about your code there?
Activity
gcanti commentedon Apr 29, 2017
Here's another repro which involves other modules.
Worth noting that with the following example the code completion feature in VSCode with TypeScript v2.2.2 hangs with CPU 100%
In the
Array.tsmodule, if I remove the currying in the definition oftraverse, i.e fromto
both the compilation crash and the VSCode hanging go away
[-]FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory (TS v2.3.1)[/-][+]TS v2.3.1 runs out of memory compiling FP library[/+]sledorze commentedon May 2, 2017
Nathan Shively-Sanders (@sandersn) One repo showing the last issue Giulio Canti (@gcanti) reported (in case it could help) :
https://github.com/sledorze/vscode-hanging
sandersn commentedon May 2, 2017
I can't repro this with
typescript@next. Can you trytypescript@next?gcanti commentedon May 3, 2017
With TypeScript 2.4.0-dev.20170502
sandersn commentedon May 3, 2017
I can't repro that exact behaviour in VS Code. For me, initial load time is very long and then if I type a dot after
validationI get completions one time. Afterwards I just getLoading...indicating that the language service is not responsive. Does VSCode itself become unresponsive for you?Are you using
"typescript.tsdk"to point totypescript@next? Here's mysettings.json{ "typescript.tsdk": "/media/nathansa/src2/ts/built/local", "typescript.tsserver.trace": "off", // ... other config stuff ... }Yours will be somewhat different since you want to point to
typescript@nextinstalled from npm instead of built locally from source.OliverJAsh commentedon May 3, 2017
I have a project that uses fp-ts and compilation still fails with this memory error on
typescript@next:gcanti commentedon May 3, 2017
Nathan Shively-Sanders (@sandersn) 👍 That's the exact behaviour I'm experimenting
No, only the Code Helper is unresponsive (I must close and reopen vscode to regain the functionality)
Yes
15 remaining items
sandersn commentedon May 15, 2017
Stéphane Le Dorze (@sledorze) the inference-too-deep cap isn't configurable right now. Setting it too low will start to create bogus inferences of
{}. Maybe we should revisit the value, but I don't think it should be configurable. The only time you need it, you're avoiding an architectural problem of the compiler.Node crashes don't give much of the stack, as you can see. I debugged using the following:
$ node --inspect --debug_brk ~/ts/built/local/tsc.jsThen I opened Chrome to the provided URL and let the compiler run for a while. Each time I did this there were many recursive calls in inference on the stack, so I guessed that inference was causing the out-of-memory crash. (You can substitute any copy of
tsc.jsthat you have, you don't need to build a copy yourself.)sandersn commentedon May 15, 2017
Update from talking to Anders Hejlsberg (@ahejlsberg). The inference-too-deep cap should maybe be removed entirely — it was a mistake from when we believed that inference should behave similarly to assignability checking.
Anders Hejlsberg (@ahejlsberg) is working on a fix that just quits when inference sees an instantiation of a type that it has seen before. That should fix this bug.
I'll also add fp-ts to our real-world code test suite after the bug is fixed so that we can catch compiler bugs in this library and similar FP/monad libraries.
sandersn commentedon May 17, 2017
fp-ts is now part of our RWC corpus so we should notice any performance regressions in the future.
OliverJAsh commentedon May 20, 2017
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.
OliverJAsh commentedon May 22, 2017
Nathan Shively-Sanders (@sandersn) Do you have any idea what is causing the above?
sledorze commentedon May 23, 2017
Nathan Shively-Sanders (@sandersn) note that the problem happens with fp-ts when there's a type error in the program, not compiling an actually well typed program (this is from my observations).
Also considering this problem, the worst case is not when one changes some code and have the compiler getting lost in inference, the real issue is when one upgrade a library and it breaks the compiler without any clue where the type error is and how to fix it.
sledorze commentedon May 23, 2017
Nathan Shively-Sanders (@sandersn) it should be reopened IMHO
sandersn commentedon May 23, 2017
Stéphane Le Dorze (@sledorze) I opened a new bug based on Oliver Joseph Ash (@OliverJAsh)'s repro: #16029. If you have another repro please link to it there.
I'm keeping this bug closed just to make bookkeeping simpler. And it's unlikely that the compiler is getting stuck in inference again (or at least, for the same reason).
bryanerayner commentedon Aug 13, 2017
I'm not sure whether or not the pain point I had today was caused by this issue, but I also was running into the problem of Node running out of space on the heap.
I reverted to 2.3.2, and was able to successfully compile. If you guys can nail down this bug, it would be greatly appreciated!
sandersn commentedon Aug 16, 2017
Bryan Rayner (@bryanerayner) there are, unfortunately, many reasons for typescript to run out of memory while compiling fp-ts. The root cause of this issue is definitely fixed: type inference no longer recursively examines types that it has already seen. But (for example) assignability checking still does recursively examine types. It's likely that the issue you're hitting is different. Can you open a new issue and give some detail about your code there?