Skip to content

Maximum call stack size exceeded #21003

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

Closed
thehardship opened this issue Jan 4, 2018 · 9 comments
Closed

Maximum call stack size exceeded #21003

thehardship opened this issue Jan 4, 2018 · 9 comments
Assignees
Labels
Bug A bug in TypeScript

Comments

@thehardship
Copy link

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.

@RyanCavanaugh
Copy link
Member

@thehardship is the file here auto-generated?

@mhegazy mhegazy added the Needs More Info The issue still hasn't been fully clarified label Jan 4, 2018
@thehardship
Copy link
Author

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
Copy link
Contributor

mhegazy commented 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
Copy link
Author

All those lines are inside a init static function the gets called when my app starts by an asset manager class.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 8, 2018

do you have a sample we can look at?

@thehardship
Copy link
Author

AssetSoundPack.ts.zip

@thehardship
Copy link
Author

thehardship commented 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.

@mhegazy mhegazy added this to the TypeScript 2.7.1 milestone Jan 9, 2018
@mhegazy mhegazy added Bug A bug in TypeScript and removed Needs More Info The issue still hasn't been fully clarified labels Jan 9, 2018
@ahejlsberg
Copy link
Member

@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
Copy link
Author

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 ....

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants