Skip to content

ng serve doesn't re-render files most of the time #5117

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
mp-tbianchi opened this issue Feb 28, 2017 · 50 comments
Closed

ng serve doesn't re-render files most of the time #5117

mp-tbianchi opened this issue Feb 28, 2017 · 50 comments

Comments

@mp-tbianchi
Copy link

OS?

Windows 10

Versions.

@angular/cli: 1.0.0-rc.0
node: 7.5.0
os: win32 x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-rc.0
@angular/compiler-cli: 2.4.8

Repro steps.

Happens all the time since update from beta version

Since I updated, ng serve doesn't rerender the file.
It sees the files that have changed and launches a recompilation but the changes don't get included.
It doesn't do this for a couple of recompilations then it refuses to update the files.

What kind of details can I give you?

Thanks

@julianobrasil
Copy link

julianobrasil commented Mar 1, 2017

Noticed it here too.

@zhaojunjie163
Copy link

The same issue I encountered since I updated to 1.0.0-rc.0

@mfreirehfexp
Copy link

Hi, same here

I've installed everything today and after the first launch (with ng serve), every change is listened and the page is rebooted but the changes to the TS are not updated (the TS is not compiled or something)

I've to kill the liveserver and start it again for every change

OS?

Windows 10

Versions.

@angular/cli: 1.0.0-rc.0
node: 6.10.0
os: win32 x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-rc.0
@angular/compiler-cli: 2.4.8
@ngtools/webpack: 1.2.11

@Evekt
Copy link

Evekt commented Mar 2, 2017

Hi,

i have the same issue, but it worked 2 Days ago with the 1.0.0-beta.32 Version.

OS:
Windows 7 64Bit

Version:
@angular/cli: 1.0.0-rc.0
node: 7.7.1
os: win32 x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.0
@angular/compiler-cli: 2.4.9

@mp-tbianchi
Copy link
Author

@Momotanien Did you have a different version 2 days ago?

@Evekt
Copy link

Evekt commented Mar 2, 2017

@mp-tbianchi Ups, sorry forgot to mention it. I updated my entry.

@instantepiphany
Copy link

instantepiphany commented Mar 3, 2017

I had the same issue with rc.0.

@instantepiphany
Copy link

I believe this may be fixed by a pending PR: #5164

@mfreirehfexp
Copy link

Hi
I've updated to @angular/cli: 1.0.0-rc.1and the problem still remains
I deleted the hole node_modules after the update and reinstall everything

@crain
Copy link

crain commented Mar 7, 2017

Is @angular/cli: 1.0.0-rc.1 released? I can't find it under https://github.com/angular/angular-cli/releases.

@mp-tbianchi
Copy link
Author

Maybe he meant this commit :

214be99

@mfreirehfexp
Copy link

Sorry
Probably it was a mistake, I put 1.0.0-rc.1 manually on my project and update all.
I check it with ng version and didn't realise it could not be publicly released yet

@filipesilva
Copy link
Contributor

I can't reproduce this in a brand new project. Can you give me exact repro steps? e.g. the project where this happens (a new project for instance, all commands you run to see this, the exact file you change.

@filipesilva
Copy link
Contributor

#5137 might be related, but it happens exclusively with --aot.

@ovalol
Copy link

ovalol commented Mar 8, 2017

I had the same issue with @angular/[email protected].
Since I updgrade from [email protected] Webpack successfully compile changes in ts files but they are not correctly loaded in browser. I have to rerun ng serve to get changes correctly loaded in broswer. Changes are only correctly compile when I change an import in typescript file.
It works fine with html and scss files.

I create a brand new project with @angular/[email protected] and got same issue.

OS

Windows 7 x64

Version

@angular/cli : 1.0.0-rc.1
@angular/compiler-cli : 2.4.9
node : 7.5.0

@filipesilva
Copy link
Contributor

filipesilva commented Mar 8, 2017

@ovalol I really need exact reproduction steps, otherwise there isn't much I can do but wait for it to happen randomly.

@mfreirehfexp
Copy link

Hi
I'm using W10
I only used the "--scss" flag to get all the scss files compiled and included (great option btw)
The other change I did was the custom theme option and added the new Angular Material
I continued working with routers, ngrx/store, and firebase.
So far it is still happening randomly, but only in TS changes, not in templates or scss changes.
I'll try to make a repo so you can be able to test it
Thanks!

@ovalol
Copy link

ovalol commented Mar 8, 2017

@filipesilva here steps to reproduce

Steps

  • ng new foo
  • cd foo
  • npm start
  • ng g component bar
  • change {{title}} by <app-bar></app-bar> in app.component.html
  • change bar template with {{title}}
  • add title attribute to BarComponent class with a default value (ex: 'foo-bar').
  • Webpack compile correctly but an empty page is display.
  • rerun npm start and now page correctly display 'foo-bar' string

@mp-tbianchi
Copy link
Author

Hey, I just tried creating a new project too.

  1. ng new testrepro
  2. cd testrepro
  3. ng serve
  4. Modify AppComponent, for example :
export class AppComponent implements OnInit {
  title = 'app works!';

  private testVar: string;

  ngOnInit(){
    console.log(4);

    this.testVar = 'blabla';
  }
}

Console says recompiling..., lists files that are recompiling and then compiled successfully.
But changes can not be seen in the browser.

@mfreirehfexp
Copy link

One thing to add
if the page doesn't update and I add an empty line and save the page doesn't still shows the changes. I mean the TS compiler gets freeze, doesn't recover from that point.

@filipesilva
Copy link
Contributor

@ovalol I tried following your steps exactly as you posted, looking at the changes in the browser, and I could always see the correct output (first app works, then bar works, then nothing, then foo-bar). I didn't need to restart the server to see changes.

@mp-tbianchi I tried your changes as well, and could see 4 printed in the console log.

@mfreirehfexp I haven't seen that behaviour yet but will keep an eye out for it.

I noticed that you three are using Windows (7 and 10). I am using Windows as well and can't see this... maybe there's something else at play.

Are you using a symlink or a juntion on your project path? Is there anything else odd you've seen? Do you get vendor.bundle.js on builds?

@mp-tbianchi
Copy link
Author

@filipesilva I don't have any symlink or junctions in the path.

I've had the bug on "old" projects that have been updated to the latest angular/cli and also new projects (in the example above). Both projects are in separate folders.
For vendor.bundle.js, do you mean if the file is generated? In that case, yes it is.

@ovalol
Copy link

ovalol commented Mar 8, 2017

@filipesilva I m not using symlink or anything else. Everything works fine with the previous version[email protected].
And vendor.bundle.js is correctly generated.

@mp-tbianchi
Copy link
Author

Oh, I just noticed something very weird.

What IDE/Editor do you all use?

When I use webstorm to modify the file : if I save with CTRL+S, sometimes the change is seen, sometimes not (I track this by checking if [rendered] is present on the main.bundle.js line).
If I use Webstorm's auto save by navigating to my console (Conemu) without CTRL+S, the change is seen less often.

But if I modify the file with Notepad++ and save with CTRL+S, the [rendered] appears everytime.

@mfreirehfexp
Copy link

@mp-tbianchi I also use Webstorm
haven't try with Notepad, I will in a few moments
@filipesilva I'll copy the state on the next ocurrence

@ovalol
Copy link

ovalol commented Mar 8, 2017

I use webstorm to.
I disable Use "safe write" option and everything seems ok.

@mp-tbianchi
Copy link
Author

https://webpack.github.io/docs/troubleshooting.html#file-saves-in-webstorm-don-t-trigger-the-watcher

huh... The more you know.... But it's weird I didn't have this problem before

@filipesilva
Copy link
Contributor

That's very good to hear! I know it sucks to have to disable safe write though, so I'm leaving this issue open to see if we can find a way that isn't necessary.

I also added it to FAQs so other people can find it.

Thanks to all that helped test this and came up with solutions, you guys rock!

@instantepiphany
Copy link

I had this issue on NVIM/VIM, not using Webstorm.

@micsimon
Copy link

i have exactly the same issue on Win 10, with IntelliJ IDEA and rc0-rc4. an "old" cli beta-version works perfectly. deactivating "safe write" fixed it for me.

@instantepiphany
vim has probably a similar "safe write" behavior

@sjanofsky
Copy link

I had the same problem until I stopped using --aot=true and now anytime I save a file the changes are picked up properly.

What is aot doing that would cause the changes not to be picked up?

@jamilalisgandarov
Copy link

Guys, I am using Visual Studio Code and getting same problem, I couldn't find 'safe write' thing in my IDE.

@mfreirehfexp
Copy link

Hi @jamilalisgandarov
The 'safe-write' option is a Webstorm config, I don't know if VisualStudio has such an option

@hpawe01
Copy link

hpawe01 commented Apr 11, 2017

@instantepiphany, with VIM you can use the solution from here:
:set backupcopy=yes

@instantepiphany
Copy link

@hpawe01 This seems to fix the issue for me, thanks so much for the link!

@Tommyf
Copy link

Tommyf commented May 12, 2017

Are there two different mechanisms being used to detect the changes? When I save in VIM (without the backupcopy setting) ng serve recompiles, but whatever does the recompiling is not picking up the actual change...

@filipesilva
Copy link
Contributor

Consolidating this thread with #1610, it's roughly the same and better to keep discussion in a single place.

@xiehongyang
Copy link

@ovalol u are totally right

@mejmo
Copy link

mejmo commented Jun 1, 2017

The same behaviour here with 1.0.0. The changes are applied in 50% of cases. The browser gets updated, but the change of the .ts file is not there. Safe-write option in WebStorm enabled.

@xiehongyang
Copy link

@mejmo make Safe-write option in WebStorm disabled.

@mejmo
Copy link

mejmo commented Jun 2, 2017

It helped and solved the issue. Thank you.

@ghost
Copy link

ghost commented Oct 3, 2017

@filipesilva Instead of disabling safe-write is it possible to base watches off of actual file changes?

Clearly the mtime of a file will change, but if the contents are exactly the same should it really fire off a recompile?

If I have webstorm open, and I just click on the window, and then click on the browser window, it still recompiles, interrupting my workflow. Even if the file hasn't changed.

@ghost
Copy link

ghost commented Oct 3, 2017

What is the "safe-write" setting for SourceTree? For some reason whatever SourceTree does to refresh is causing a recompile. This seems kind of silly because some other alert could come along and force Windows to refresh it's GDM. It doesn't seem like "developing angular" should be interrupted by whichever OS you are using.

@ghost
Copy link

ghost commented Oct 3, 2017

Disabling safe-write didn't change anything for me. Still recompiles even though nothing has changed.

@ghost
Copy link

ghost commented Oct 16, 2017

I have the opposite of this problem, it reloads too often because webstorm changes file times behind my back and their is no way to ignore it with the cli #8033 (comment)

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests