[dotnet-watch] Clear WebSocket env vars in ClearHotReloadEnvironmentVariables#53999
Merged
jonathanpeppers merged 1 commit intodotnet:release/10.0.4xxfrom Apr 21, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates dotnet-watch hot reload startup-hook behavior to fully clear transport-specific environment variables so they don’t leak into child processes (named pipe and WebSocket parity).
Changes:
- Clear
DOTNET_WATCH_HOTRELOAD_WEBSOCKET_ENDPOINTinClearHotReloadEnvironmentVariables. - Clear
DOTNET_WATCH_HOTRELOAD_WEBSOCKET_KEYinClearHotReloadEnvironmentVariables.
Comment on lines
307
to
310
| Environment.SetEnvironmentVariable(AgentEnvironmentVariables.DotNetWatchHotReloadNamedPipeName, null); | ||
| Environment.SetEnvironmentVariable(AgentEnvironmentVariables.DotNetWatchHotReloadWebSocketEndpoint, null); | ||
| Environment.SetEnvironmentVariable(AgentEnvironmentVariables.DotNetWatchHotReloadWebSocketKey, null); | ||
| Environment.SetEnvironmentVariable(AgentEnvironmentVariables.HotReloadDeltaClientLogMessages, null); |
There was a problem hiding this comment.
Add/extend a unit test to cover the new behavior: when DOTNET_WATCH_HOTRELOAD_WEBSOCKET_ENDPOINT / DOTNET_WATCH_HOTRELOAD_WEBSOCKET_KEY are set, ClearHotReloadEnvironmentVariables should clear them (and restore originals in a finally to avoid test cross-contamination).
Member
Author
There was a problem hiding this comment.
The existing env var clearing (named pipe, log messages) also has no test verifying they're unset.
ClearHotReloadEnvironmentVariables already clears the named pipe env var (DOTNET_WATCH_HOTRELOAD_NAMEDPIPE_NAME) but does not clear the WebSocket equivalents (DOTNET_WATCH_HOTRELOAD_WEBSOCKET_ENDPOINT and DOTNET_WATCH_HOTRELOAD_WEBSOCKET_KEY). Fix parity so WebSocket env vars are also cleared for child processes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
061374b to
25a6e70
Compare
Member
|
rebasing with the branch now that #53993 is merged. |
tmat
approved these changes
Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I just noticed this reading the code -- not sure if it actually causes a problem, but should probably be fixed.
ClearHotReloadEnvironmentVariablesalready clears the named pipe env var ($DOTNET_WATCH_HOTRELOAD_NAMEDPIPE_NAME) but does not clear the WebSocket equivalents ($DOTNET_WATCH_HOTRELOAD_WEBSOCKET_ENDPOINT and $DOTNET_WATCH_HOTRELOAD_WEBSOCKET_KEY). Fix parity so WebSocket env vars are also cleared for child processes.