Skip to content

fix(devserver): cap concurrent hot-reload workspaces, disable oldest without closing the socket - #24240

Merged
dr1rrb merged 1 commit into
masterfrom
dev/devserver-cap-hr-workspaces
Aug 28, 2026
Merged

dr1rrb merged 1 commit into
masterfrom
dev/devserver-cap-hr-workspaces

Conversation

@dr1rrb

@dr1rrb dr1rrb commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #24205

PR Type:

🐞 Bugfix

What changed? 🚀

A reused / long-lived dev-server accumulates one Roslyn workspace + EnC session (~hundreds of MB) per connected app, with no upper bound: each /rc app connection owns its own workspace, and reconnect / restart loops (or a stale half-open socket) stack them — measured at ~+500 MB per extra connection (see #24205 / #24151).

This adds a process-wide cap on concurrent hot-reload workspaces:

  • New HotReloadWorkspaceRegistry (in Uno.UI.RemoteControl.ServerCore), a DI singleton configured through the Options pattern: HotReloadWorkspaceOptions.MaxConcurrentWorkspaces (default 5), bound at startup from the HotReload configuration section and read via IOptionsMonitor (e.g. HotReload:MaxConcurrentWorkspaces, UNO_DEVSERVER_HotReload__MaxConcurrentWorkspaces, or --HotReload:MaxConcurrentWorkspaces through the existing config pipeline).
  • Each app connection that initializes a hot-reload workspace registers a slot once it is Ready. IDE-driven connections never load a workspace, so only app workspaces are counted.
  • When capacity is exceeded, the oldest slot(s) have hot reload disabled: their workspace / DebuggingSession is disposed to reclaim the memory, and the end-of-life is reported to the app over the existing hot-reload status channel (HotReloadTracker.SendUpdate(serverError: …) + HotReloadEvent.Disabled).
  • Crucially, the /rc connection is kept open — only the HR processor's workspace is torn down — so the client does not trigger an auto-reconnect / retry storm. The file-update gate reports Failed (terminal-but-not-closed), never Disposed.
  • A configuration change that lowers the capacity is applied live via IOptionsMonitor.OnChange (the surplus oldest workspaces are evicted immediately); the registry disposes that subscription (IDisposable).

This is terminal for the evicted connection (its app is told hot reload ended and why); the app gets a fresh HR session on its next launch.

PR Checklist ✅

  • 🧪 Added Given_HotReloadWorkspaceRegistry (eviction: oldest-first, keeps Capacity slots; unregister; idempotent register; live capacity-drop).
  • 📚 Docs — N/A.
  • 🖼️ Screenshots — N/A (no UI change).
  • ❗ Contains NO breaking changes (apps within the cap are unaffected; the connection is never force-closed).
  • 👀 Reviewed 2 other open pull requests.

Copilot AI lite review requested due to automatic review settings August 27, 2026 12:17
@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a process-wide cap on concurrent app hot-reload workspaces in the DevServer Host to prevent unbounded Roslyn workspace / EnC session memory growth across long-lived /rc connections.

Changes:

  • Introduces HotReloadWorkspaceRegistry + HotReloadWorkspaceOptions to evict oldest hot-reload workspaces beyond a configured capacity.
  • Registers app-workspace slots once the workspace reaches Ready, and disables hot reload (without closing the socket) on evicted connections.
  • Adds unit tests covering eviction order, idempotent registration, unregister behavior, and live capacity drops.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Uno.UI.RemoteControl.ServerCore/Uno.UI.RemoteControl.ServerCore.csproj Adds Options package dependency used by the new registry/options types.
src/Uno.UI.RemoteControl.ServerCore/InProcess/InProcessDevServer.cs Registers options + singleton registry in the in-process server DI setup.
src/Uno.UI.RemoteControl.ServerCore/HotReloadWorkspaceRegistry.cs New registry/options + slot contract to cap concurrent hot-reload workspaces and evict oldest.
src/Uno.UI.RemoteControl.Server/Helpers/ServiceCollectionExtensions.cs Registers options + singleton registry in the shared remote-control server DI setup.
src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.MetadataUpdate.cs Registers the connection’s slot when the workspace becomes Ready.
src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.cs Implements eviction handling by disabling hot reload without closing the socket.
src/Uno.UI.RemoteControl.Host/Program.cs Binds HotReloadWorkspaceOptions from configuration at host startup.
src/Uno.UI.RemoteControl.DevServer.Tests/Given_HotReloadWorkspaceRegistry.cs Adds tests for eviction, unregister, idempotency, and live capacity drop behavior.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@unodevops

Copy link
Copy Markdown
Contributor

…without closing the socket

A reused/long-lived dev-server accumulates one Roslyn workspace + EnC session
(~hundreds of MB) per connected app, with no bound: each app connection keeps
its own workspace, and reconnect/restart loops stack them. See #24205 / #24151.

Introduce HotReloadWorkspaceRegistry, a DI singleton configured through the
Options pattern (HotReloadWorkspaceOptions, MaxConcurrentWorkspaces, default 5)
bound from the 'HotReload' configuration section and read via IOptionsMonitor.
Each app connection that initializes a hot-reload workspace registers a slot
once it is Ready; IDE-driven connections (no workspace) never register, so only
app workspaces are counted. When capacity is exceeded, the oldest slot(s) have
hot reload disabled: their workspace / DebuggingSession is disposed to reclaim
the memory, the end-of-life is reported to the app over the hot-reload status
channel (SendUpdate + HotReloadEvent.Disabled), and the /rc connection is kept
open so the client does not trigger an auto-reconnect storm. A configuration
change that lowers the capacity is applied live via IOptionsMonitor.OnChange
(the surplus oldest workspaces are evicted immediately); the registry disposes
that subscription (IDisposable).

Adds Given_HotReloadWorkspaceRegistry covering eviction (oldest-first, keeps
Capacity slots), unregister, idempotent register, and live capacity-drop.

Fixes #24205
Copilot AI review requested due to automatic review settings August 27, 2026 13:34
@dr1rrb
dr1rrb force-pushed the dev/devserver-cap-hr-workspaces branch from e02e174 to 6f95b92 Compare August 27, 2026 13:34
@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

src/Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor.cs:513

  • During workspace-cap eviction, the workspace CancellationTokenSource is canceled but not disposed. Since this runs on a reused dev-server and evictions can happen repeatedly, this can leak wait handles over time.
			var workspace = _workspace;
			_workspace = null;
			workspace?.Ct.Cancel();

@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@dr1rrb
dr1rrb merged commit 89800ef into master Aug 28, 2026
69 of 71 checks passed
@dr1rrb
dr1rrb deleted the dev/devserver-cap-hr-workspaces branch August 28, 2026 12:17
@dr1rrb

dr1rrb commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

@Mergifyio backport release/stable/6.7

@mergify

mergify Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.7

✅ Backports have been created

Details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DevServer: cap concurrent app Hot Reload workspaces; disable HR on oldest beyond N without closing the socket

4 participants