Skip to content
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

CLI Hot reload Blazor wasm just doesn't work. #40587

Closed
1 task done
ziaulhasanhamim opened this issue Mar 8, 2022 · 24 comments · Fixed by dotnet/sdk#27699
Closed
1 task done

CLI Hot reload Blazor wasm just doesn't work. #40587

ziaulhasanhamim opened this issue Mar 8, 2022 · 24 comments · Fixed by dotnet/sdk#27699
Assignees
Labels
area-blazor Includes: Blazor, Razor Components area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-dotnetwatch This issue is related to the dotnet-watch command-line tool (now external) feature-hot-reload This issue is related to the Hot Reload feaature investigate Priority:2 Work that is important, but not critical for the release
Milestone

Comments

@ziaulhasanhamim
Copy link

ziaulhasanhamim commented Mar 8, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

There were many issues about dotnet watch not working with blazor wasm. #38561, #36723, #40091 etc. It was mentioned there that the issue is fixed in .net 6.0.2. But it's not. The issue is there still. Furthermore, there are no responses now on those issues when it was informed that in .net6.0.2 it's not working. Very disappointing behavior.

dotnet watch --verbose logs

watch : Project supports hot reload and was configured to run with the default run-command. 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 : Building...
watch : Started 'C:\Program Files\dotnet\dotnet.exe' '' with process id 9496
  Determining projects to restore...
  Restored C:\Users\ziaul\Sources\BlazorWasmApp\BlazorWasmApp.csproj (in 1.39 sec).
  BlazorWasmApp -> C:\Users\ziaul\Sources\BlazorWasmApp\bin\Debug\net6.0\BlazorWasmApp.dll
  BlazorWasmApp (Blazor output) -> C:\Users\ziaul\Sources\BlazorWasmApp\bin\Debug\net6.0\wwwroot
watch : Process id 9496 ran for 27116ms
watch : Running MSBuild target 'GenerateWatchList' on 'C:\Users\ziaul\Sources\BlazorWasmApp\BlazorWasmApp.csproj'
watch : Started 'C:\Program Files\dotnet\dotnet.exe' '' with process id 9176
watch : Process id 9176 ran for 3657ms
watch : Watching 28 file(s) for changes
watch : dotnet-watch is configured to launch a browser on ASP.NET Core application startup.
watch : Configuring the app to use browser-refresh middleware.
watch : Refresh server running at wss://localhost:58192,ws://localhost:58193.
watch : HotReloadProfile: BlazorWebAssembly.
watch : Waiting for a browser to connect
watch : Started 'dotnet' '"C:\Users\ziaul\.nuget\packages\microsoft.aspnetcore.components.webassembly.devserver\6.0.2\build\../tools/blazor-devserver.dll" --applicationpath "C:\Users\ziaul\Sources\BlazorWasmApp\bin\Debug\net6.0\BlazorWasmApp.dll"' with process id 8976
watch : Running dotnet with the following arguments: run
watch : Started
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:7020
watch : Launching browser.
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5152
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: C:\Users\ziaul\Sources\BlazorWasmApp
watch : Hot reload capabilities: .
watch : File changed: C:\Users\ziaul\Sources\BlazorWasmApp\Pages\Index.razor.
watch : No deltas modified. Applying changes to clear diagnostics.
watch : Received 1 from browser in [Count: 1, MessageType: Binary, EndOfMessage: True].
watch : No hot reload changes to apply.
watch : Hot reload change handled in 6599.4355ms.

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

6.0.200

Anything else?

No response

@TanayParikh TanayParikh added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-hot-reload This issue is related to the Hot Reload feaature labels Mar 8, 2022
@javiercn javiercn added area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI feature-dotnetwatch This issue is related to the dotnet-watch command-line tool (now external) labels Mar 8, 2022
@javiercn
Copy link
Member

javiercn commented Mar 8, 2022

@ziaulhasanhamim thanks for contacting us.

Could you provide a minimal repro project as a public github repository with detailed steps on how to trigger the issue so that we can make progress investigating?

@javiercn javiercn added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Mar 8, 2022
@ghost
Copy link

ghost commented Mar 8, 2022

Hi @ziaulhasanhamim. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@ziaulhasanhamim
Copy link
Author

ziaulhasanhamim commented Mar 9, 2022

Could you provide a minimal repro project as a public github repository with detailed steps on how to trigger the issue so that we can make progress investigating?

dotnet new blazorwasm
then dotnet watch --verbose
you can see there watch : Hot reload capabilities: .
So there are no capabilities for hot reload.
Also sometimes it shows watch : Hot reload capabilities: Baseline
Then it works well

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Mar 9, 2022
@mkArtakMSFT mkArtakMSFT added this to the .NET 7 Planning milestone Mar 9, 2022
@ghost
Copy link

ghost commented Mar 9, 2022

Thanks for contacting us.

We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@danroth27
Copy link
Member

you can see there watch : Hot reload capabilities: .

@ziaulhasanhamim How often does this happen for you? I tried these steps several times, but I always ended up with Baseline and hot reload worked fine. Have you noticed anything that might be causing the capabilities to not get identified correctly?

@davidivkovic
Copy link

Not sure this is the right place, but figured it would be better than opening a new issue.
A similar problem occurs when running dotnet watch for a webapi inside a docker container on wsl2.
Works fine on the host Windows machine, but not inside the container.
Dotnet version 6.0.201

info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://[::]:80
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: /src/
watch : Hot reload capabilities: Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters.
watch : File changed: /src/Controllers/WeatherForecastController.cs.
watch : No deltas modified. Applying changes to clear diagnostics.
watch : No hot reload changes to apply.
watch : Hot reload change handled in 25385.07ms.

@ziaulhasanhamim
Copy link
Author

ziaulhasanhamim commented Mar 10, 2022

@ziaulhasanhamim How often does this happen for you? I tried these steps several times, but I always ended up with Baseline and hot reload worked fine. Have you noticed anything that might be causing the capabilities to not get identified correctly?

Whenever the build takes longer it happens. Maybe it's a timeout problem. I have seen @pranavkm mention that.

@danroth27
Copy link
Member

A similar problem occurs when running dotnet watch for a webapi inside a docker container on wsl2.
Works fine on the host Windows machine, but not inside the container.

@davidivkovic I think you should open a separate issue with detailed repro steps for the problem you're seeing. Hot reload is supported in WSL2 and so far we haven't been able to reproduce the issue you're seeing.

@mkArtakMSFT mkArtakMSFT added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Mar 23, 2022
@mkArtakMSFT mkArtakMSFT removed this from the .NET 7 Planning milestone Mar 23, 2022
@ghost
Copy link

ghost commented Mar 23, 2022

Hi @ziaulhasanhamim. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@ziaulhasanhamim
Copy link
Author

Open question? What is the question? And why author feedback was added? What feedback do I need to provide?

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Mar 24, 2022
@mkArtakMSFT mkArtakMSFT added investigate and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Mar 24, 2022
@mkArtakMSFT mkArtakMSFT added this to the .NET 7 Planning milestone Mar 24, 2022
@ghost
Copy link

ghost commented Mar 24, 2022

Thanks for contacting us.
We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@mkArtakMSFT mkArtakMSFT added Priority:2 Work that is important, but not critical for the release triaged labels Mar 30, 2022
@szalapski
Copy link

I am experiencing this too. "No hot reload changes to apply." is very wrong. It is so close, it just needs to apply the changes to my .razor file, push the new client code etc.

@Apollo3zehn
Copy link

Apollo3zehn commented Jul 5, 2022

Me too, sometimes I get "Hot reload capabilities: Baseline." (hot reload works) and other times I get "Hot reload capabilities: ." (hot reload does not work).

Occasionally it helps to delete all build artifacts and rebuild everything. However, if it is really a build time issue as @ziaulhasanhamim suggested, deleting the build artifacts should make it worse ... its confusing and quite annoying :-(

Edit: I am working under Kubuntu 22.04 using vscode.

@ziaulhasanhamim
Copy link
Author

@Apollo3zehn i find that this problem is directly related to build time. When you less build time the hot reload works. But when you have got a larger build time it will surely fail

@Apollo3zehn
Copy link

Thanks, I switched from my Windows Notebook to a Kubuntu VM running on that Notebook and of course the build time increased.

I guess it fails silently either here:

https://github.com/dotnet/sdk/blob/94502f47c07d09c215b458b7529341d3981d8ccc/src/BuiltInTools/dotnet-watch/HotReload/DefaultDeltaApplier.cs#L43

Or here:
https://github.com/dotnet/sdk/blob/94502f47c07d09c215b458b7529341d3981d8ccc/src/BuiltInTools/dotnet-watch/HotReload/BlazorWebAssemblyDeltaApplier.cs#L63

There is a 10 second timeout specified. Maybe it is related to that.

@ziaulhasanhamim
Copy link
Author

ziaulhasanhamim commented Jul 6, 2022

Yeah, timeout is maybe the problem #38561 (comment). Why there is a need for a timeout. I don't think there is a timeout for Blazor Server or asp.net core. And if the timeout is really needed then give the user the ability to change the duration via environment variables.

@iampluque
Copy link

iampluque commented Jul 13, 2022

A similar problem occurs when running dotnet watch for a webapi inside a docker container on wsl2.
Works fine on the host Windows machine, but not inside the container.

@davidivkovic I think you should open a separate issue with detailed repro steps for the problem you're seeing. Hot reload is supported in WSL2 and so far we haven't been able to reproduce the issue you're seeing.

@davidivkovic Did you open the issue? or resolved it? ... i'm having the exact same issue!

@davidivkovic
Copy link

@iampluque

Never resolved the issue.
Stopped using dotnet, switched to quarkus.

@Apollo3zehn
Copy link

Apollo3zehn commented Jul 29, 2022

I switched from my Kubuntu 22.04 VM to a native Kubuntu 22.04 system on an Intel NUC 11 Performance. Build is much faster now ... and suddenly hot reload works flawlessly 🥳! So I can confirm this issue is related to build times (or to the web app's start-up time).

@szalapski
Copy link

szalapski commented Jul 29, 2022 via email

@Apollo3zehn
Copy link

I would first make sure there are no script load errors / connection errors in the browser web tools. IIRC, I had some issues there because the developer certifcate was not trusted in Firefox. One of the scripts is responsible for the hot reload functionality.

Then use dotnet watch instead of dotnet watch run.

If also not working with cleared bin/obj folders, and verbose output (dotnet watch -v) does not print anything useful, my last resort would be to try to build dotnet watch myself and increase the timeout I have linked above. But I don't know if compiling dotnet watch is easy enough.

@danroth27
Copy link
Member

@tmat I hit this issue the first time I ran a new Blazor WebAssembly project with .NET SDK 6.0.400:

~\desktop> dotnet new blazorwasm -o BlazorWasmApp
The template "Blazor WebAssembly App" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/6.0-third-party-notices for details.

Processing post-creation actions...
Running 'dotnet restore' on C:\Users\user\desktop\BlazorWasmApp\BlazorWasmApp.csproj...
  Determining projects to restore...
  Restored C:\Users\user\desktop\BlazorWasmApp\BlazorWasmApp.csproj (in 6.64 sec).
Restore succeeded.

~\desktop> cd .\BlazorWasmApp\
~\desktop\BlazorWasmApp> code .
~\desktop\BlazorWasmApp> dotnet watch
eload.
  💡 Press "Ctrl + R" to restart.
dotnet watch 🔧 Building...
  Determining projects to restore...
  All projects are up-to-date for restore.
  BlazorWasmApp -> C:\Users\user\desktop\BlazorWasmApp\bin\Debug\net6.0\BlazorWasmApp.dll
  BlazorWasmApp (Blazor output) -> C:\Users\user\desktop\BlazorWasmApp\bin\Debug\net6.0\wwwroot
dotnet watch 🚀 Started
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:7104
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5041
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: C:\Users\user\desktop\BlazorWasmApp
dotnet watch ⌚ File changed: .\Pages\Index.razor.
dotnet watch ⌚ No hot reload changes to apply.
dotnet watch ⌚ File changed: .\Pages\Index.razor.
dotnet watch ⌚ No hot reload changes to apply.
dotnet watch ⌚ File changed: .\Pages\Counter.razor.
dotnet watch ⌚ No hot reload changes to apply.
info: Microsoft.Hosting.Lifetime[0]
dotnet watch 🛑 Shutdown requested. Press Ctrl+C again to force exit.

The browser UI showed the hot reload check mark, but the app UI didn't actually update.

The 2nd time I ran dotnet watch on the same project it worked fine.

@ziaulhasanhamim
Copy link
Author

@danroth27 there might be problems about build times and timeout in blazor wasm hot reload. At first build it took little long so hot reload didn't work. At second build it was comparatively faster so hot reload was working

@wocar
Copy link

wocar commented Aug 24, 2022

I confirm that there is a timeout issue regarding build times.

I'm using intel mac, and I have to close everything, and run the backing api's in a remote box, because otherwise my machine will get slow, therefore hot-reload not working. Also I have to run dotnet watch twice. The second one is the one that works.

When it works the output is:
dotnet watch 🔥 Hot reload capabilities: Baseline

When it doesn't
dotnet watch 🔥 Hot reload capabilities: .

Another thing that might affect hot reload working or not, is the boot time of the application. So I set my startup url to a /blank page.

Combining these two things (remote backing api, /blank page) I manage to get hot-reload working.

@mkArtakMSFT mkArtakMSFT modified the milestones: .NET 7 Planning, 7.0-rc2 Sep 6, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly feature-dotnetwatch This issue is related to the dotnet-watch command-line tool (now external) feature-hot-reload This issue is related to the Hot Reload feaature investigate Priority:2 Work that is important, but not critical for the release
Projects
None yet
Development

Successfully merging a pull request may close this issue.