Blazor wasm: dotnet watch hot reload 100% CPU on Ubuntu
See original GitHub issueDescribe the bug
When running a hosted blazor wasm app, dotnet watch hangs with 100% CPU usage after a file is changed on Ubuntu 16.04 and 20.04 (tested platforms, could affect others). It detects the file has changed and then hangs. Does not exit when Ctrl+C is pressed and must be killed with SIGTERM.
To Reproduce
- Create blazor server app:
dotnet new blazorwasm --hosted -o TestingHotReloadWasm --no-https
- Start app:
cd Server && dotnet watch
- Make change to
Client/Pages/Index.razor
- edit<h1>
text. Save file dotnet watch
will detect file change but will hang and use 100% CPU. Pressing Ctrl+C will not quit the command
❯ dotnet watch --verbose
watch : Found HotReloadProfile=blazorwasmhosted. Watching with hot-reload
watch : Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload. Press "Ctrl + R" to restart.
watch : Evaluating dotnet-watch file set.
watch : Running MSBuild target 'GenerateWatchList' on '/home/stephen.foulds/Documents/tmp/TestingHotReloadWasm/Server/TestingHotReloadWasm.Server.csproj'
watch : Started '/snap/dotnet-sdk/127/dotnet' '' with process id 12860
watch : Process id 12860 ran for 678ms
watch : Watching 36 file(s) for changes
watch : Building...
watch : Started '/snap/dotnet-sdk/127/dotnet' '' with process id 12919
Determining projects to restore...
All projects are up-to-date for restore.
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
TestingHotReloadWasm.Shared -> /home/stephen.foulds/Documents/tmp/TestingHotReloadWasm/Shared/bin/Debug/net6.0/TestingHotReloadWasm.Shared.dll
TestingHotReloadWasm.Client -> /home/stephen.foulds/Documents/tmp/TestingHotReloadWasm/Client/bin/Debug/net6.0/TestingHotReloadWasm.Client.dll
TestingHotReloadWasm.Client (Blazor output) -> /home/stephen.foulds/Documents/tmp/TestingHotReloadWasm/Client/bin/Debug/net6.0/wwwroot
TestingHotReloadWasm.Server -> /home/stephen.foulds/Documents/tmp/TestingHotReloadWasm/Server/bin/Debug/net6.0/TestingHotReloadWasm.Server.dll
watch : Process id 12919 ran for 1602ms
watch : dotnet-watch is configured to launch a browser on ASP.NET Core application startup.
watch : Refresh server running at wss://localhost:33783.
watch : Using MSBuild at '/snap/dotnet-sdk/127/sdk/6.0.100-preview.4.21255.9/' to load projects.
watch : Started '/home/stephen.foulds/Documents/tmp/TestingHotReloadWasm/Server/bin/Debug/net6.0/TestingHotReloadWasm.Server' '' with process id 13033
watch : Running TestingHotReloadWasm with the following arguments: run
watch : Started
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
watch : Launching browser.
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /home/stephen.foulds/Documents/tmp/TestingHotReloadWasm/Server
watch : File changed: /home/stephen.foulds/Documents/tmp/TestingHotReloadWasm/Client/Pages/Index.razor.
Exceptions (if any)
Further technical details
Reproduced in the following environments. One installed from snap, the other installed manually by downloading tar.gz and unpacking to $HOME/dotnet.
❯ dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.100-preview.4.21255.9
Commit: 950e4949a7
Runtime Environment:
OS Name: ubuntu
OS Version: 16.04
OS Platform: Linux
RID: ubuntu.16.04-x64
Base Path: /snap/dotnet-sdk/127/sdk/6.0.100-preview.4.21255.9/
Host (useful for support):
Version: 6.0.0-preview.4.21253.7
Commit: bfd6048a60
.NET SDKs installed:
6.0.100-preview.4.21255.9 [/snap/dotnet-sdk/127/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.0-preview.4.21253.5 [/snap/dotnet-sdk/127/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.0-preview.4.21253.7 [/snap/dotnet-sdk/127/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
vagrant@ubuntu-focal:~$ dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.100-preview.4.21255.9
Commit: 950e4949a7
Runtime Environment:
OS Name: ubuntu
OS Version: 20.04
OS Platform: Linux
RID: ubuntu.20.04-x64
Base Path: /home/vagrant/dotnet/sdk/6.0.100-preview.4.21255.9/
Host (useful for support):
Version: 6.0.0-preview.4.21253.7
Commit: bfd6048a60
.NET SDKs installed:
6.0.100-preview.4.21255.9 [/home/vagrant/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.0-preview.4.21253.5 [/home/vagrant/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.0-preview.4.21253.7 [/home/vagrant/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Hot Reload not so hot. : r/Blazor
I started it through the dotnet watch run command and hot reload worked fine for blazor server and wasm. skill issue maybe?
Read more >Weird errors problem with dotnet watch with blazor/wasm.
I start the API part with CTRL+F5, and I start the Blazor part from the Windows terminal with dotnet watch (because I want...
Read more >Hot reload blazor via dotnet watch not working
1 Answer 1 · 1. I don't know why, but it work for me too. Blazor Webassembly. – sptremblay · That doesn't make...
Read more >VS Code and Blazor WASM: Debug with Hot Reload
This is a post to share my findings on how to set up VS Code to debug a standalone Blazor WebAssembly application with...
Read more >What's New in v22.2 - Latest Version
New products and capabilities introduced across the entire DevExpress product line with v22.2 - the second major release of 2022. The latest version....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi.
Re-tested with latest versions (preview 6 and 7) using the same setup as outlined previously (in Vagrant VM).
Behaviour has changed, but unfortunately hot reload does not work.
Currently seeing the following behaviour in preview 7:
dotnet watch
Client/Pages
directorydotnet watch
detects a change has been madeFile changed
log message printed to consoledotnet watch
results in the following exceptionNo high CPU usage is observed this time.
dotnet info from latest test:
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
See our Issue Management Policies for more information.