Repository navigation
Maximum call stack size exceeded #21003
Description
tsc 2.6.2
in a static class meant to reference assets, the following line is repeated for each game asset, each class references only one type of asset, in this case with this the sound class:
AssetSoundPack.uniqueClassReference['assetx'] = new SoundContextResource('contextresources/sound/resource_12312.mp3', 'sound', 1, false, false, false);
This project makes heavy use of sound assets and this is where the tsc compiler gives up, commenting out half those assets (4000 lines) makes the compiler happy and the file compiles but with 8000 it gives up (that file alone makes 500K).
Additionally is there anyway to increase the call stack limit temporary?
Cannot compile a .ts file with 8000 lines
/usr/local/lib/node_modules/typescript/lib/tsc.js:56173
throw e;
^
RangeError: Maximum call stack size exceeded
at isMatchingReference (/usr/local/lib/node_modules/typescript/lib/tsc.js:26978:37)
at isMatchingReference (/usr/local/lib/node_modules/typescript/lib/tsc.js:26991:25)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27583:21)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
at getTypeAtFlowArrayMutation (/usr/local/lib/node_modules/typescript/lib/tsc.js:27584:36)
at getTypeAtFlowNode (/usr/local/lib/node_modules/typescript/lib/tsc.js:27529:32)
Expected Behavior: Although unusual in size, there shouldn't be an issue in compiling files that are 8000 lines and more.
Actual behavior: Exit with a Maximum call stack size exceeded, file did not compile.
Activity
RyanCavanaugh commentedon Jan 4, 2018
thehardship is the file here auto-generated?
thehardship commentedon Jan 4, 2018
Yes it is, it's an in-house program that generate the files and code for those assets, now we have 8 projects running with this without problem but this one has the longest sound file.
My quick workaround so far: I commented out the last 4000 lines and compiled the file without errors, saved the generated file then commented out the first 4000 lines and compiled, then I put everything back together in the compiled file. So tsc had no problem compiling 8000 lines as long as 4000 of them were commented out (it came out commented out in the generated js file as well) just it couldn't do all 8000 lines at once.
mhegazy commentedon Jan 4, 2018
are these on the top level of the file, or inside a function? does moving them inside a function change the behavior?
thehardship commentedon Jan 8, 2018
All those lines are inside a init static function the gets called when my app starts by an asset manager class.
mhegazy commentedon Jan 8, 2018
do you have a sample we can look at?
thehardship commentedon Jan 9, 2018
AssetSoundPack.ts.zip
thehardship commentedon Jan 9, 2018
AssetSoundPack.ts.zip
(sorry I think I clicked the wrong buttons)
This attached file reproduces the problem on its own (the original has imports).
I tested it by leaving it alone in a project (no other .ts file whatsoever) and compiling and I got the same error/result.
ahejlsberg commentedon Jan 9, 2018
thehardship I'm pretty sure this bug was fixed by #18246 which was in the 2.6 release. I can't reproduce the problem with any of the 2.6.x compilers nor with the nightly build. However, the error does reproduce with 2.5. Can you verify you're on 2.6 or later?
thehardship commentedon Jan 10, 2018
I got caught again in VSC false version display, sorry about that, VSC was displaying 2.6.2 but compiling in 2.5.3. I ran an update and can confirm my file does compile now. I wish the VSC team would consider it makes more sense to display the tsc version VSC actually uses to compile files ....