8000 dotnet watch hot reloads for all non-code files - potential infinite reload loop · Issue #44910 · dotnet/sdk · GitHub
[go: up one dir, main page]

Skip to content

dotnet watch hot reloads for all non-code files - potential infinite reload loop #44910

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

Open
seangwright opened this issue Nov 16, 2024 · 17 comments
Labels
Area-Watch untriaged Request triage from a team member

Comments

@seangwright
Copy link
seangwright commented Nov 16, 2024

Describe the bug

I'm running dotnet watch in the directory of an ASP.NET Core 8.0 application using the .NET 9 SDK.

My app generates non-code files in the ~\App_Data directory as part of a background process (this includes binary, xml, json, and other non code files). When this happens, dotnet watch records the files being created or modified and will even hot reload

For example

dotnet watch ⌚ Files added: .\App_Data\LuceneSearch\QANDA_SEARCH\i-g0000059-p_False\write.lock, .\App_Data\LuceneSearch\QANDA_SEARCH\i-g0000059-p_False_taxonomy\write.lock
dotnet watch ⌚ Files added: .\App_Data\LuceneSearch\QANDA_SEARCH\i-g0000059-p_False\write.lock, .\App_Data\LuceneSearch\QANDA_SEARCH\i-g0000059-p_False_taxonomy\write.lock
dotnet watch ⌚ No hot reload changes to apply.

I have tried ignoring specific files but none of the recommendations work. Even if they did work, there's no reason I should have to explicitly ignore some .txt files in App_Data to keep my app from reloading.

To Reproduce

  1. Clone https://github.com/seangwright/dotnet-watch-dotnet-sdk9-bug
  2. Run dotnet watch
  3. See home page load in browser
  4. See infinite number of .txt files created in App_Data\Test because dotnet watch keeps reloading the page

Exceptions (if any)

dotnet watch should not process files that have nothing to do with rebuilding or hot-reloading my .NET application.

Further technical details

.NET SDK:
 Version:           9.0.100
 Commit:            59db016f11
 Workload version:  9.0.100-manifests.c6f19616
 MSBuild version:   17.12.7+5b8665660

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100\

.NET workloads installed:
 [aspire]
   Installation Source: VS 17.12.35506.116
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:              Msi

Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.0
  Architecture: x64
  Commit:       9d5a6a9aa4

.NET SDKs installed:
  8.0.404 [C:\Program Files\dotnet\sdk]
  9.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  E:\workspace\dotnet\ASPNETMVC8_NET9SDK\global.json

This bug negatively impacts any project that generates files in the project during runtime - ASPNET Core apps with client assets, files uploaded/imported to the file system, log files, ect...

@ghost ghost added Area-Watch untriaged Request triage from a team member labels Nov 16, 2024
@seangwright seangwright changed the title dotnet watch records new non-code files added under App_Data dotnet watch records new non-code files Nov 16, 2024
@seangwright seangwright changed the title dotnet watch records new non-code files dotnet watch hot reloads for all non-code files - potential infinite reload loop Nov 21, 2024
@hopsoftsro
Copy link

I had similar issue to exclude some directory from dotnet watch but it didn't work

@patrikholcak
Copy link
patrikholcak commented Dec 18, 2024

This is frustrating, particularly with webpack hot reload + emit files, where every time you save a js file, it emits hot reload chunk + json, which are added to the watch. It really slows down the reload after a couple of file changes and hogs CPU 😬

@seangwright
Copy link
Author

I'm still not using .NET 9, 3 months after its release, because of this issue.
Because the issue is untriaged, I can't identify which .NET SDK update would include a potential fix for it.

I tried 9.0.102, which did not resolve the problem.

@Santas
Copy link
Santas commented Jan 22, 2025

I'm considering every day if it is not worth it to downgrade back to .NET 8 every time the dotnet watch has some issue.

@seangwright
Copy link
Author

4 months after release and I'm still using .NET 8 because of this issue.

@tmat
Copy link
Member
tmat commented Mar 6, 2025

Starting with 9.0.200 dotnet-watch ignores files in output directories (bin, obj) and in directories starting with ..

Further customization of ignored files is tracked by issue #45539.

should not process files that have nothing to do with rebuilding or hot-reloading my .NET application.

We do not know whether other files that are being added have anything to do with building until we evaluate the project.
If the evaluation determines the files have no effect on the compilation "No hot reload changes to apply." is reported as shown in your output example. This message means the change had no effect.

@seangwright
Copy link
Author

The issue is dotnet watch now watches a lot more than it used to.

It feels much more like opt-out configuration is required than opt-in.

Since the opt-out configuration does not work today I cannot use dotnet watch in .NET 9.

@tmat
Copy link
Member
tmat commented Mar 6, 2025

@seangwright I'm not sure I understand why dotnet-watch reporting "No hot reload changes to apply" is a blocker. Could you elaborate?

@willdean
Copy link

@seangwright I'm not sure I understand why dotnet-watch reporting "No hot reload changes to apply" is a blocker. Could you elaborate?

I can't speak for the OP, but dotnet watch in 9.0 is
A. Much slower than it used to be
and
B. Outputs a lot more messages about noticing changes in irrelevant files than it used to.

Of course, 'A' might not be related to 'B' but to those of us outside the black box it seems reasonable to feel that there might be a connection.

@tmat
Copy link
Member
tmat commented Mar 12, 2025

@willdean Is that only in scenarios where there are file writes to directories under the project directory other than obj/bin? What is an example of irrelevant file change?

@seangwright
Copy link
Author

@seangwright I'm not sure I understand why dotnet-watch reporting "No hot reload changes to apply" is a blocker. Could you elaborate?

@tmat Did you take a look at my reproduction in my original post?

I work with web apps that generate files in the file system while running. Each time this happens the web page reloads/refreshes from dotnet watch. These generated files are not generated in . directories or obj/bin so the improvement in 9.0.200 doesn't help.

None of this was a problem in .NET 8.

@tmat
Copy link
Member
tmat commented Mar 13, 2025

@seangwright
Yes, I'm aware of that scenario. I was wondering if there are other scenarios.

@mhegreberg
Copy link

I'm seeing this for the .db-journal file after editing any records in a sqlite database stored within the same directory as the code

@angularsen
Copy link

Related, dotnet watch is significantly slower when editing files with Rider vs VSCode, around 3x slower.

Workaround is to disable Backup files before saving in Rider Settings > Appearance & Behavior > System Settings > Autosave.

Created a separate issue to track slow hot reload with temporary backup files:
#47912

@aaronamm
Copy link
aaronamm commented Apr 16, 2025

I found the same issue on .NET 9 as well.
My project saved a new image file to App_Data folder and then dotnet watch started to reload a web page with the following message:
dotnet watch ⌚ Files added: ...
I use VS Code and WSL2 + Ubuntu 22.04.

@seangwright
Copy link
Author

@tmat I'm assuming this won't be fixed for .NET 9 (which I've basically skipped using). Will this be fixed for .NET 10?

@tmat
Copy link
Member
tmat commented May 13, 2025

@seangwright Will try but can't make promises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Watch untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

9 participants
0