Skip to content

RangeError: Maximum call stack size exceeded #12804

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
maghis opened this issue Dec 9, 2016 · 7 comments · Fixed by #12818
Closed

RangeError: Maximum call stack size exceeded #12804

maghis opened this issue Dec 9, 2016 · 7 comments · Fixed by #12818
Labels
Bug A bug in TypeScript

Comments

@maghis
Copy link

maghis commented Dec 9, 2016

TypeScript Version: 2.1.4

tsc crashes with RangeError: Maximum call stack size exceeded

Code
I managed to repro with:

  • install latest aws-sdk npm install aws-sdk
  • one single file /src/test.ts
import { DynamoDB } from "aws-sdk";

export class MyClass {
    public async updateItem() {
    }
}
  • tsconfig.json
{
    "compilerOptions": {
        "module": "commonjs",
        "declaration": true,
        "outDir": "build",
        "lib": [
            "es6"
        ],
        "types": [
            "node"
        ]
    },
    "include": [
        "src/**/*"
    ],
    "exclude": [
        "node_modules"
    ]
}
@maghis
Copy link
Author

maghis commented Dec 9, 2016

@sandersn I was able to repro with TS 2.0.10 too.

@sandersn
Copy link
Member

sandersn commented Dec 9, 2016

Thanks! Did you get any of the stack trace too?

@vladima
Copy link
Contributor

vladima commented Dec 9, 2016

seems to be related to declaration emit

/home/vladima/sources/git/TypeScript/built/local/tsc.js:62576
                throw e;
                ^

RangeError: Maximum call stack size exceeded
    at resolveAlias (/home/vladima/sources/git/TypeScript/built/local/tsc.js:25178:22)
    at /home/vladima/sources/git/TypeScript/built/local/tsc.js:25627:58
    at Object.forEachProperty (/home/vladima/sources/git/TypeScript/built/local/tsc.js:1946:26)
    at getAccessibleSymbolChainFromSymbolTable (/home/vladima/sources/git/TypeScript/built/local/tsc.js:25620:27)
    at /home/vladima/sources/git/TypeScript/built/local/tsc.js:25633:97
    at Object.forEachProperty (/home/vladima/sources/git/TypeScript/built/local/tsc.js:1946:26)
    at getAccessibleSymbolChainFromSymbolTable (/home/vladima/sources/git/TypeScript/built/local/tsc.js:25620:27)
    at /home/vladima/sources/git/TypeScript/built/local/tsc.js:25633:97
    at Object.forEachProperty (/home/vladima/sources/git/TypeScript/built/local/tsc.js:1946:26)
    at getAccessibleSymbolChainFromSymbolTable (/home/vladima/sources/git/TypeScript/built/local/tsc.js:25620:27)

@vladima
Copy link
Contributor

vladima commented Dec 9, 2016

simplified repro (compile with -d -t es6)

// app.ts
import * as Db from "./db"
export async function foo() {
}
// db.d.ts
declare namespace Db {
    export import Types = Db;
}

export = Db;

@mhegazy mhegazy added the Bug A bug in TypeScript label Dec 9, 2016
@mhegazy mhegazy added this to the TypeScript 2.1.5 milestone Dec 9, 2016
@maghis
Copy link
Author

maghis commented Dec 9, 2016

Thanks @vladima

@shirakaba
Copy link

shirakaba commented Jan 17, 2017

Don't know whether this qualifies as an issue of Webpack, but in case anyone runs into this problem for the same reasons as me again: This error will arise, even in Webpack 2.2.0-rc.7, if you accidentally load in a .ts (MPEG-TS video transport stream) file along with your intended TypeScript files. The only thing needed to reproduce this error is an MPEG-TS file (linked below), but here is my full setup:

  • package.json:
{
  "name": "bugger",
  "version": "1.0.0",
  "description": "",
  "main": "webpack.config.js",
  "scripts": { "start": "webpack --config webpack.config.js --display-error-details" },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "ts-loader": "^1.3.3",
    "typescript": "^2.1.5",
    "webpack": "^2.2.0-rc.7"
  }
}
  • tsconfig.json:
{
    "compilerOptions": {
        "watch": true,
        "target": "es5",
        "baseUrl": ".",
        "allowJs": true
    }
}
  • webpack.config.js:
module.exports = {
    entry: "./src/index.ts",
    output: { filename: "bundle.js" },
    devtool: 'source-map',
    resolve: { extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"] },
    module: {
        loaders: [
            // We are incorrectly assuming here that all .ts files are TypeScript files
            { test: /\.tsx?$/, loader: "ts-loader" }
        ]
    }
}

... and stacktrace (actually not sure whether it's ts-loader's problem or Webpack's, now that I look at it):

ts-loader: Using typescript@2.1.5 and /Users/shirakaba/Sites/tsconfig.json
/Users/shirakaba/Sites/node_modules/ts-loader/dist/utils.js:7
    Array.prototype.splice.apply(existingErrors, [0, 0].concat(errorsToPush));
                           ^

RangeError: Maximum call stack size exceeded
    at Object.registerWebpackErrors (/Users/shirakaba/Sites/node_modules/ts-loader/dist/utils.js:7:28)
    at /Users/shirakaba/Sites/node_modules/ts-loader/dist/after-compile.js:108:19
    at Array.forEach (native)
    at provideErrorsToWebpack (/Users/shirakaba/Sites/node_modules/ts-loader/dist/after-compile.js:89:10)
    at Compiler.<anonymous> (/Users/shirakaba/Sites/node_modules/ts-loader/dist/after-compile.js:21:9)
    at next (/Users/shirakaba/Sites/node_modules/tapable/lib/Tapable.js:140:14)
    at Compiler.<anonymous> (/Users/shirakaba/Sites/node_modules/webpack/lib/CachePlugin.js:62:5)
    at Compiler.applyPluginsAsyncSeries (/Users/shirakaba/Sites/node_modules/tapable/lib/Tapable.js:142:13)
    at /Users/shirakaba/Sites/node_modules/webpack/lib/Compiler.js:474:10
    at Compilation.applyPluginsAsyncSeries (/Users/shirakaba/Sites/node_modules/tapable/lib/Tapable.js:131:46)
    at self.applyPluginsAsync.err (/Users/shirakaba/Sites/node_modules/webpack/lib/Compilation.js:615:19)
    at Compilation.applyPluginsAsyncSeries (/Users/shirakaba/Sites/node_modules/tapable/lib/Tapable.js:131:46)
    at self.applyPluginsAsync.err (/Users/shirakaba/Sites/node_modules/webpack/lib/Compilation.js:606:11)
    at Compilation.applyPluginsAsyncSeries (/Users/shirakaba/Sites/node_modules/tapable/lib/Tapable.js:131:46)
    at self.applyPluginsAsync.err (/Users/shirakaba/Sites/node_modules/webpack/lib/Compilation.js:601:10)
    at Compilation.applyPluginsAsyncSeries (/Users/shirakaba/Sites/node_modules/tapable/lib/Tapable.js:131:46)
    at sealPart2 (/Users/shirakaba/Sites/node_modules/webpack/lib/Compilation.js:597:9)
    at Compilation.applyPluginsAsyncSeries (/Users/shirakaba/Sites/node_modules/tapable/lib/Tapable.js:131:46)
    at Compilation.seal (/Users/shirakaba/Sites/node_modules/webpack/lib/Compilation.js:545:8)
    at /Users/shirakaba/Sites/node_modules/webpack/lib/Compiler.js:471:16
    at /Users/shirakaba/Sites/node_modules/tapable/lib/Tapable.js:225:11
    at _addModuleChain (/Users/shirakaba/Sites/node_modules/webpack/lib/Compilation.js:452:11)
    at processModuleDependencies.err (/Users/shirakaba/Sites/node_modules/webpack/lib/Compilation.js:423:13)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

As a solution, you can either find a way to explicitly exclude the MPEG-TS files from being loaded, or just rename them to .tsv.

@sandersn
Copy link
Member

@shirakaba your crash probably doesn't have the same root cause as this bug; most crashes that result from analysing non typescript files are stack overflows. Can you file a new bug instead? Thanks.

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

Successfully merging a pull request may close this issue.

5 participants