Skip to content
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

Compiler hang when importing big JS file with --allowJs #17033

Open
pjmolina opened this issue Jul 8, 2017 · 3 comments
Open

Compiler hang when importing big JS file with --allowJs #17033

pjmolina opened this issue Jul 8, 2017 · 3 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@pjmolina
Copy link

pjmolina commented Jul 8, 2017

TypeScript Version: 2.4.1

Repro project
When importing a big JS file (a working parser) (245 Kbytes commonjs format) (with --allowJs enabled) the compiler hangs forever. Minimal repro project provided: tsc-hang-00

Expected behavior:
Compilations ends with or without errors.

Actual behavior:
Compilations hangs forever and keeps consuming CPU.

Tests conditions

  • Windows 10, NodeJS 8.0, TS 2.4.1
  • Travis: Linux Container, NodeJS 8.0, TS 2.4.1
@filipesilva
Copy link
Contributor

I tried to profile what's going on here and trying to capture a CPU profile for any length of time (even 1s) will cause the Chrome profiler to crash while processing the CPU profile.

@sandersn
Copy link
Member

sandersn commented Jan 2, 2018

Profiling probably isn't useful for a 245k file — it's usually a bug or an algorithmic performance problem, both of which usually express themselves as very deep stacks. My initial debugging method is to start debugging and just pause a few times. I'll fall back to profiling (or printf debugging of caches) if there doesn't seem to be a pattern in the locations.

There are two relevant meanings of 'location': which node is currently being checked, and where the instruction pointer is when debugging is paused.

@filipesilva
Copy link
Contributor

Heya, just wanted to say I have another, simpler repro at https://github.com/filipesilva/tsc-allowjs-big-file. It was inspired by @dzonatan's repro at angular/angular-cli#9636 (comment).

It just has a class with a thousand methods:

export class BigClass {
  myVar: any;

  method000() { return this.myVar; }
  method001() { return this.myVar; }
  // ...
  method999() { return this.myVar; }
}

Running npm test on that repository will compile this typescript file to javascript, and then compile the resulting javascript file with --allowJs.

This yields the RangeError: Maximum call stack size exceeded error with TS 2.7.2 and 2.8.4. However, with TS 2.9.1, no error is thrown and compilation succeeds.

hansl pushed a commit to angular/angular-cli that referenced this issue Jun 6, 2018
hansl pushed a commit to angular/angular-cli that referenced this issue Jun 6, 2018
hansl pushed a commit to angular/angular-cli that referenced this issue Jun 6, 2018
@mhegazy mhegazy modified the milestones: TypeScript 3.0, Future Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants