https://github.com/angularsen/dotnet9-watch-slow-repro
Repro for https://github.com/dotnet/sdk/issues/47179
https://github.com/angularsen/dotnet9-watch-slow-repro
Last synced: 9 months ago
JSON representation
Repro for https://github.com/dotnet/sdk/issues/47179
- Host: GitHub
- URL: https://github.com/angularsen/dotnet9-watch-slow-repro
- Owner: angularsen
- Created: 2025-03-25T09:06:25.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-03-25T09:29:20.000Z (9 months ago)
- Last Synced: 2025-03-25T10:26:56.187Z (9 months ago)
- Language: CSS
- Size: 866 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Repro for slow dotnet watch with Blazor on .NET9
Related:
- [hot reload takes too much time · Issue \#47179 · dotnet/sdk](https://github.com/dotnet/sdk/issues/47179)
- [dotnet 9, "dotnet watch" is really bad in Blazor Server · Issue \#45810 · dotnet/sdk](https://github.com/dotnet/sdk/issues/45810)
## Problem
1. `dotnet watch` is slower on net9 than net8, in particular the _first_ change can take 10-20 seconds vs a few seconds for a trivial change to `.razor` files in our large Blazor Server app. (1)
2. Blazor seems to do a page reload after hot reload in our app, but have not yet been able to create a repro of this behavior in these sample apps. See details below.
(1)
In 9.0.2 SDK release, the hot reload was 10-20x slower for every change, but in 9.0.3 SDK release only the first hot reload is 10-20x slow and subsequent changes are fast.
`9.0.104`, `9.0.202` and `9.0.300-preview.0.25174.3` all exhibit the slow first hot reload, and in our app, also a special page reload.
In our app, these versions also do a special page reload upon hot reload. Details below.
## To run this sample
Run both projects in two separate shells:
```sh
dotnet watch --verbose --project Blazor8
```
```sh
dotnet watch --verbose --project Blazor9
```
- Wait for browser to launch for each project.
- Edit `Components/Pages/Home.razor` in either project, and change the title text or something trivial.
## Observations in template apps
- Simulating a slow `OnInitializedAsync` with Task.Delay, delays the hot reload on both (probably by design)
## Observations in our large Blazor Server app
- On net9, hot reload incurs what seems like a special page reload. The circuit stays connected and no new HTTP GET request to Blazor, but the page is pre-rendered again, and all scoped services are recreated and re-initialized.
- This page load is slow in our app and delays hot reload, and this did not happen in net8 SDK.

