angular-cli: Hot reload freezes if mistake in template file is corrected
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
While playing with Angular in dev mode I get stuck frequently at
Rerunning app with ‘ng serve’ resolves but it’s annoying.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Application bundle generation complete. [0.074 seconds]
Reloading client(s)...
Please provide the environment you discovered this bug in (run ng version
)
Angular CLI: 17.0.0
Node: v18.13.0
Anything else?
No response
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 15
- Comments: 29 (1 by maintainers)
I did some investigation and was able to reproduce consistently with the following steps:
npm init @angular@17.0.1 ng-new && cd ng-new
ng serve
app.component.html
.<div>Hello, world!</div
(no>
).>
.app.component.html
no longer trigger a rebuild.A few more notes:
index.html
(although it doesn’t seem to be watched at all which is likely a separate bug).Digging down this looks like a Windows pathing issue. After every build we check if any files were added or removed from the compilation and update the file watcher to match. To do this we compare the files we were watching before a build with the files we found during the build (relevant code). Inspecting this state I found:
C:\\Users\\Doug\\Source\\ng-new\\src\\app\\app.component.html
C:/Users/Doug/Source/ng-new/src/app/app.component.html
Due to the different separators, the CLI thinks we stopped watching
app.component.html
and removes it from the watched file set. Seems like we just need to make sure our paths are normalized so they are added/removed from the watched set correctly. The bad paths are likely coming from some of the tools we’re invoking (TypeScript, esbuild, etc.). So we’ll want to normalize those to a consistent structure when we receive them.@clydin landed a potential fix in https://github.com/angular/angular-cli/pull/26393. I confirmed that this appears to fix the issue in my testing.
It’s unfortunately pretty late on a Friday right now, but I can follow up with a patch release Monday morning. This should be in the
17.0.2
release.Hi! I can confirm the same behaviour when getting html error, then fixing it, then getting stuck in reloading.
17.0.2 should be out now with the fix. Please try it out and let us know if you’re still seeing any challenges with the
ng serve
experience.@dgp1130 Hey Douglas, can confirm it’s fixed 😃
I can confirm that it is now working correctly in 17.0.1
I can also confirm that the same things happens with
@angular-devkit/build-angular:browser-esbuild
The same for me
I am using Windows 11 Home 22H2 and “builder”: “@angular-devkit/build-angular:application”. I’d say it’s pretty frequent - once every 5-6 file saves and mainly I’ve been fiddling with html files.
NG_BUILD_DEBUG_PERF=1 doesn’t log as it gets stuck totally and only “Reloading client(s)” is there. Will try disabling parallelization later.
Update: happens on both scenarios when there’s some error and error html message is rendered, once making html template correct it loads up but hot reload stops working. Websocket connection is still in pending status while browsing network tab.
So far, so good for me as well/
Same here, happens random after 2 - 7 reloads:
“builder”: “@angular-devkit/build-angular:application”,
Angular CLI: 17.0.0 Node: 20.9.0 Package Manager: npm 10.2.3 OS: win32 x64 W11 22H2 Chrome 119