Fix process cleanup timeout causing port binding errors in no-hot-reload mode #51632
+36
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Running
dotnet watch run --no-hot-reloadfails with "address already in use" errors after file changes because the process cleanup timeout was set to 0 seconds in no-hot-reload mode, force-killing the dev server before it could release network ports.Changes
EnvironmentOptions.cs: Remove conditional logic that returned
TimeSpan.FromSeconds(0)for no-hot-reload mode. Always return 5-second default timeout regardless of hot reload state to allow graceful shutdown.EnvironmentOptionsTests.cs: Add tests verifying timeout behavior returns 5 seconds for both hot reload enabled/disabled cases, and respects environment variable overrides.
The
DOTNET_WATCH_PROCESS_CLEANUP_TIMEOUT_MSenvironment variable can still override the default timeout.Original prompt
This section details on the original issue you should resolve
<issue_title>[.NET10RC2]
dotnet watch run --no-hot-reloadfails</issue_title><issue_description>### Describe the bug
Running
dotnet watch run --no-hot-reloaddoes not work correctly, at least for blazor-wasm projects.When a rebuild is triggered, it does not shut down the old dev server, causing the new one to fail with a bind error.
To Reproduce
dotnet new blazorwasm -e -p --no-https)dotnet watch run -c Release --property WarningLevel=0 --no-hot-reloadExceptions (if any)
Further technical details
details of dotnet --info
``` .NET SDK: Version: 10.0.100-rc.2.25502.107 Commit: 89c8f6a112 Workload version: 10.0.100-manifests.0cee6f9c MSBuild version: 18.0.0-preview-25502-107+89c8f6a11
Runtime Environment:
OS Name: nixos
OS Version: 25.11
OS Platform: Linux
RID: linux-x64
Base Path: /nix/store/aj7lxjjn3rl2bazsv9p0dfnv069j6rsq-dotnet-sdk-10.0.100-rc.2.25502.107/share/dotnet/sdk/10.0.100-rc.2.25502.107/
.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.
Host:
Version: 10.0.0-rc.2.25502.107
Architecture: x64
Commit: 89c8f6a112
.NET SDKs installed:
10.0.100-rc.2.25502.107 [/nix/store/aj7lxjjn3rl2ba...
dotnet watch run --no-hot-reloadfails #51476✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.