Skip to content

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

Merged
agneszitte merged 1 commit into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24240
Sep 11, 2026
Merged

agneszitte merged 1 commit into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-24240

Conversation

@mergify

@mergify mergify Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

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.

This is an automatic backport of pull request #24240 done by [Mergify](https://mergify.com).

…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

(cherry picked from commit 6f95b92)

@dr1rrb dr1rrb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Backport approved — straight mergify backport of an already-approved master fix.

@agneszitte agneszitte added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 4, 2026
@agneszitte
agneszitte merged commit 63a40c8 into release/stable/6.7 Sep 11, 2026
13 checks passed
@agneszitte
agneszitte deleted the mergify/bp/release/stable/6.7/pr-24240 branch September 11, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants