question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blazor wasm: dotnet watch hot reload 100% CPU on Ubuntu

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
TeknoVenuscommented, Aug 13, 2021

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:

  • Start dotnet watch
  • Edit .razor page in Client/Pages directory
  • dotnet watch detects a change has been made
watch : File changed: /home/vagrant/hotreloadtest2/Client/Pages/Index.razor.
  • No hot reload occurs in browser
  • Editing a different page results in no File changed log message printed to console
  • Pressing Ctrl+C to terminate dotnet watch results in the following exception
watch : Shutdown requested. Press Ctrl+C again to force exit.
watch : 
Reading hot reload capabilities failed. Using default capabilities.
watch : Process id 8333 ran for 159438ms
watch : System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at Microsoft.DotNet.Watcher.Tools.BlazorWebAssemblyDeltaApplier.<>c__DisplayClass6_0.<<GetApplyUpdateCapabilitiesAsync>g__GetApplyUpdateCapabilitiesCoreAsync|0>d.MoveNext() in dotnet-watch.dll:token 0x60002a9+0x9c
--- End of stack trace from previous location ---
   at Microsoft.DotNet.Watcher.Tools.BlazorWebAssemblyHostedDeltaApplier.GetApplyUpdateCapabilitiesAsync(DotNetWatchContext context, CancellationToken cancellationToken) in dotnet-watch.dll:token 0x6000189+0xa1
   at Microsoft.DotNet.Watcher.Tools.CompilationWorkspaceProvider.GetHotReloadCapabilitiesAsync(Task`1 hotReloadCapabilitiesTask, IReporter reporter) in dotnet-watch.dll:token 0x6000193+0x64
Unhandled exception. System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at Microsoft.DotNet.Watcher.Tools.BlazorWebAssemblyDeltaApplier.<>c__DisplayClass6_0.<<GetApplyUpdateCapabilitiesAsync>g__GetApplyUpdateCapabilitiesCoreAsync|0>d.MoveNext() in dotnet-watch.dll:token 0x60002a9+0x9c
--- End of stack trace from previous location ---
   at Microsoft.DotNet.Watcher.Tools.BlazorWebAssemblyHostedDeltaApplier.GetApplyUpdateCapabilitiesAsync(DotNetWatchContext context, CancellationToken cancellationToken) in dotnet-watch.dll:token 0x6000189+0xa1
   at Microsoft.DotNet.Watcher.Tools.CompilationWorkspaceProvider.CreateProject(TaskCompletionSource`1 taskCompletionSource, Task`1 hotReloadCapabilitiesTask, String projectPath, IReporter reporter, CancellationToken cancellationToken) in dotnet-watch.dll:token 0x6000192+0x1e7
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__127_1(Object state) in System.Private.CoreLib.dll:token 0x600323f+0x0
   at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute() in System.Private.CoreLib.dll:token 0x6002f67+0x14
   at System.Threading.ThreadPoolWorkQueue.Dispatch() in System.Private.CoreLib.dll:token 0x6002f41+0x110
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() in System.Private.CoreLib.dll:token 0x600303b+0x67
   at System.Threading.Thread.StartCallback() in System.Private.CoreLib.dll:token 0x6002bb9+0xe

No high CPU usage is observed this time.

dotnet info from latest test:

.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.7.21379.14
 Commit:    22d70b47bc

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.7.21379.14/

Host (useful for support):
  Version: 6.0.0-preview.7.21377.19
  Commit:  91ba01788d

.NET SDKs installed:
  6.0.100-preview.7.21379.14 [/home/vagrant/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0-preview.7.21378.6 [/home/vagrant/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0-preview.7.21377.19 [/home/vagrant/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
0reactions
msftbot[bot]commented, Sep 13, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found