Skip to content

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

@TeknoVenus

Description

@TeknoVenus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackThe author of this issue needs to respond in order for us to continue investigating this issue.Status: No Recent Activityarea-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIfeature-hot-reloadThis issue is related to the Hot Reload feaatureinvestigate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions