Skip to content

Maximum call stack size exceeded #21003

Closed

Description

@thehardship

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

  1. RyanCavanaugh commented on Jan 4, 2018

    @RyanCavanaugh
    Member

    thehardship is the file here auto-generated?

  2. thehardship commented on Jan 4, 2018

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

  3. mhegazy commented on Jan 4, 2018

    @mhegazy
    Contributor

    are these on the top level of the file, or inside a function? does moving them inside a function change the behavior?

  4. thehardship commented on Jan 8, 2018

    @thehardship
    Author

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

  5. mhegazy commented on Jan 8, 2018

    @mhegazy
    Contributor

    do you have a sample we can look at?

  6. thehardship commented on Jan 9, 2018

    @thehardship
    Author
  7. thehardship commented on Jan 9, 2018

    @thehardship
    Author

    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.

  8. added
    BugA bug in TypeScript
    and removed
    Needs More InfoThe issue still hasn't been fully clarified
    on Jan 9, 2018
  9. ahejlsberg commented on Jan 9, 2018

    @ahejlsberg
    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?

  10. thehardship commented on Jan 10, 2018

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

  11. locked and limited conversation to collaborators on Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions