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

tsc -w is unacceptably slow #6178

Closed
oliverjanik opened this issue Dec 20, 2015 · 61 comments
Closed

tsc -w is unacceptably slow #6178

oliverjanik opened this issue Dec 20, 2015 · 61 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue High Priority

Comments

@oliverjanik
Copy link

I'm on windows. Typescript version installed via npm is 1.7.5. When I do tsc -w typescript watches for changes but its change detection is really slow. I takes about 10s before it notices I made a change and then recompiles.

What could be causing this?

Edit: Node 5.3.0

@Olgagr
Copy link

Olgagr commented Dec 21, 2015

I have the same problem with 1.7.5 on Mac. In my case, it takes ~ 5 seconds before it notices that something changed.

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Dec 21, 2015
@RyanCavanaugh
Copy link
Member

What version of node are you using?

@Olgagr
Copy link

Olgagr commented Dec 21, 2015

I'm using 5.2.0 but the same problem I had on 0.12.2. I have no problem withtsc -w in version 1.7.3.

@DanielRosenwasser
Copy link
Member

Pinging @zhengbli and @vladima.

@zhengbli zhengbli added the Bug A bug in TypeScript label Dec 21, 2015
@DanielRosenwasser
Copy link
Member

Just as a heads up everyone, you can go back to 1.7.3 with no user-facing issues. 1.7.5's only change was on file watching behavior which is what you're noticing.

@DanielRosenwasser DanielRosenwasser removed the Needs More Info The issue still hasn't been fully clarified label Dec 21, 2015
@fergusg
Copy link

fergusg commented Dec 22, 2015

FWIW, I see same problem (except even slower ~ 20s delay) on Linux w/ node 4.0.0. Still slow with current snapshot 1.8.0-dev.20151222

@oliverjanik
Copy link
Author

I tried 1.7.3 on 5.3.0/Win and it's only marginally better: 4-5s.

@deflexor
Copy link

Same issue on Linux with node 0.10. Delay is about 4-5 seconds. Tried 1.7.5 and 1.7.3 - same result.
Here is tsconfig.json:

{
    "compilerOptions": {
        "target": "ES5",
        "module": "system",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": true,
        "outDir": "./app"
    },
    "exclude": [
        "node_modules"
    ]
}

@kamilmac
Copy link

Same 5s delay here (ver 1.7.5 and 1.5.3 before) on mac with following tsconfig:

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules"
  ]
}

@FlorianBELLAZOUZ
Copy link

Same issue
5 second delay
node v4.1.0 on windows.

tsconfig.json :

{
  "compilerOptions": {
    "target": "ES5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false
  },
  "exclude": [
    "node_modules",
    ".git"
  ]
}

@stefk
Copy link

stefk commented Jan 7, 2016

Same issue on linux, node 5.1.0. Fixed with 1.7.3.

@realyze
Copy link

realyze commented Jan 8, 2016

Same issue on Mac OS X 10.11. Downgrading to 1.7.3 helps partially - sometimes the watcher fires fast, most of the time there's a big delay.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 8, 2016

PR #6026 should address this issue. We should have this in shortly. sorry for the delay.

@johnpapa
Copy link

johnpapa commented Jan 8, 2016

Thanks for the status update @mhegazy

Looking forward for th fix. This explains a slowdown I have in my angular 2 app using lite-server

@asadsahi
Copy link

asadsahi commented Jan 8, 2016

I am having slow reload with typescript 1.7+, works fine with typescript 1.6.

Anybody else?

@mhegazy
Copy link
Contributor

mhegazy commented Jan 8, 2016

@asadsahi this change was introduced between TS 1.7.3 and TS 1.7.5, if you are running into issues with TS 1.7.3 then it is a different issue.

@asadsahi
Copy link

asadsahi commented Jan 8, 2016

I am having same issue with typescript 1.7.3.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 9, 2016

@asadsahi that is a different issue then. can you provide more details? how many files do you have? can you share your configurations?

@oliverjanik
Copy link
Author

I think it's still the same issue as many commenters pointed out. There's very little difference between 1.7.3 and 1.7.5 they're both slow compared to other watchers like gulp watch or webpack watch.

@zhengbli
Copy link
Contributor

A fix was merged in master just now and will be published tomorrow via typescript@next on npm, so if anyone is willing to give it a shot it would be great. Thanks!

@mhegazy
Copy link
Contributor

mhegazy commented Jan 14, 2016

@oliverjanik, @asadsahi, @stefk, @realyze, @johnpapa, @deflexor, @FlorianBELLAZOUZ, @kamilmac, @fergusg and @Olgagr can you give typescript@next a try, and let us know if the issue has been resolved?

@fergusg
Copy link

fergusg commented Jan 14, 2016

@mhegazy It's certainly better but still slow with a ~7s lag (1.7.3 is <<1s)

Version 1.8.0-dev.20160114

@fergusg
Copy link

fergusg commented Jan 16, 2016

@zhengbli one reason for the still slightly slow change detection may be that tsc -w still seems to be watching ./node_modules dir, even though tsconfig.json has

    "exclude": [
        "node_modules"
    ]

i.e., when I touch a .ts file in node_modules, I get change detection.

@zhengbli
Copy link
Contributor

Is the .ts file in your node_modules folder referenced by your file somewhere? If so it is supposed to be watched. I tried to put a random .ts file in the node_modules folder and didn't see changes were picked up. Can you confirm?

Also, it would be of great help if you can put the error log when the tsc -w is not working stably, or point me to a sample project that could lead to a repro. Thanks!

@fergusg
Copy link

fergusg commented Jan 16, 2016

@zhengbli

In my case @next gives an error not present in 1.7.3:

> tsc -p . --sourceRoot app

node_modules/angular2/src/facade/promise.d.ts(1,10): error TS2661: 
    Cannot re-export name that is not defined in the module.

That's what I used to generate the previously described problem:

$ touch node_modules/angular2/src/facade/promise.d.ts

This triggers the change detection. I'm not explicitly referencing that file anywhere.

I'll try to get a sample project together...

@fergusg
Copy link

fergusg commented Jan 16, 2016

@zhengbli

You could try https://github.com/fergusg/my-ng2-sandbox which is what I'm using. I'm slightly embarrassed to point you at that messy hack job (not intended for anyone but me) which is a learning pit for angular 2, but what the hell...

@mhegazy
Copy link
Contributor

mhegazy commented Jan 16, 2016

@fergusg this error is caused by the fix for #6323, I will send a fix for the angular package to address the issue.

@zhengbli
Copy link
Contributor

@fergusg Thanks for the sample! Is this where the watching doesn't work consistently? I tried editing all .ts files in the app folder, and all changes were detected, so if there is a problem, it is not caused by the file name. Did you see the issue after a long session? How often do you see it stopped working?

@fergusg
Copy link

fergusg commented Jan 16, 2016

@zhengbli Sorry, I can't reproduce reliably :-(

I edit .ts files (Visual Studio Code FWIW) and mostly those changes are detected. But "from time to time" tsc -w just stops picking up those changes. Completely. Only restarting tsc -w fixes it.

@fergusg
Copy link

fergusg commented Jan 16, 2016

@zhengbli To answer your questions more explicitly:

Did you see the issue after a long session?
I saw it even after a minute or so with only 2 or 3 .ts saves

How often do you see it stopped working?
3 or 4 times in my recent session (2 hrs with constant saves)

@johnpapa
Copy link

I've run several tests and its very slow with TypeScript 1.7+. I wrote lite-server which runs browser-sync. If I run tsc with a watch and browser-sync, on typescript v 1.6 it takes about 2 seconds to reload the page when i have a 1s delay on browser sync. this is awesome.

If I run the same thing with typescript 1.7.5 or typescript@next, it takes 20+ seconds

you can repeat this by pulling the https://github.com/johnpapa/angular2-tour-of-heroes sample, npm i and run npm start from the command line.

UPDATE

if I use npm install typescript@next it is now working quickly. maybe a new rev since i last tried. here is what i have exactly

"typescript": "^1.8.0-dev.20160119"

@zhengbli
Copy link
Contributor

@johnpapa a fix for the slowness in watching mode was merged in master last week, so the one in typescripe@next has the fix in.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jan 21, 2016
@mhegazy mhegazy closed this as completed Jan 21, 2016
@johnpapa
Copy link

i see 1.8 is in this repo, is it going to npm shortly too?

@mhegazy
Copy link
Contributor

mhegazy commented Jan 21, 2016

we are closing down on 1.8 bugs. we should have something out in the next few weeks. typescript@next now should be very close to the final 1.8 drop.

@johnpapa
Copy link

ok. i saw the version here https://github.com/Microsoft/TypeScript/blob/master/package.json#L5 and got excited and confused :)

@mhegazy
Copy link
Contributor

mhegazy commented Jan 21, 2016

:) we bump up the version in master once we ship to make sure that nighties have the correct version number.

@danieleds
Copy link

@fergusg I have the same issue:

node_modules/angular2/src/facade/promise.d.ts(1,10): error TS2661:
      Cannot re-export name that is not defined in the module.

Is it a bug in tsc or in Angular?

EDIT: might be related to #6323

@vladima
Copy link
Contributor

vladima commented Jan 25, 2016

this is the issue in angular, I think that the fix is already submitted

@squarewave24
Copy link

squarewave24 commented Jul 19, 2016

im on 1.8.10 and the problem continues on mac.
that same version on windows is instantaneous. in fact it's identical package.json file as i'm following the ng2 quick start template. for some reason on a mac the changes take 5-20s to be detected


  "dependencies": {
    "@angular/common":  "2.0.0-rc.1",
    "@angular/compiler":  "2.0.0-rc.1",
    "@angular/core":  "2.0.0-rc.1",
    "@angular/http":  "2.0.0-rc.1",
    "@angular/platform-browser":  "2.0.0-rc.1",
    "@angular/platform-browser-dynamic":  "2.0.0-rc.1",
    "@angular/router":  "2.0.0-rc.1",
    "@angular/router-deprecated":  "2.0.0-rc.1",
    "@angular/upgrade":  "2.0.0-rc.1",
    "systemjs": "0.19.27",
    "core-js": "^2.4.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "zone.js": "^0.6.12",
    "angular2-in-memory-web-api": "0.0.11",
    "bootstrap": "^3.3.6"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.2.0",
    "typescript": "^1.8.10",
    "typings":"^1.0.4"
  }

@squarewave24
Copy link

squarewave24 commented Jul 26, 2016

@johnpapa running npm install typings@next screwed me up with this error typings/typings#554
fixed it by running typings install env~node -SG, but all this did not do anything for tsc change detection speed.

@squarewave24
Copy link

actually never mind, much faster now :)

@sumant30
Copy link

sumant30 commented Mar 30, 2017

I am using Node Js ver 7.8.0 and file watcher is taking loads of time recognizing my file changes. My typescript ver is 2.2.1.

@zhengbli
Copy link
Contributor

@sumant30 Can you share your tsconfig.json / OS / file system? You are using the tsc -w right?

@sumant30
Copy link

sumant30 commented Mar 31, 2017

Os : windows 7 & file system : NTFS & You are using the tsc -w right? : Yes

And my tsconfig.json is below

{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"./node_modules/@types/"
]
},
"compileOnSave": true,
"exclude": [
"node_modules/",
"**/
-aot.ts"
]
}

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue High Priority
Projects
None yet
Development

No branches or pull requests