Repository navigation
fix(devserver): cap concurrent hot-reload workspaces, disable oldest without closing the socket (backport #24240) - #24413
Merged
agneszitte merged 1 commit intoSep 11, 2026
Conversation
…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
approved these changes
Sep 4, 2026
dr1rrb
left a comment
Member
There was a problem hiding this comment.
Backport approved — straight mergify backport of an already-approved master fix.
2 of 5 tasks
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.
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
/rcapp 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:
HotReloadWorkspaceRegistry(inUno.UI.RemoteControl.ServerCore), a DI singleton configured through the Options pattern:HotReloadWorkspaceOptions.MaxConcurrentWorkspaces(default 5), bound at startup from theHotReloadconfiguration section and read viaIOptionsMonitor(e.g.HotReload:MaxConcurrentWorkspaces,UNO_DEVSERVER_HotReload__MaxConcurrentWorkspaces, or--HotReload:MaxConcurrentWorkspacesthrough the existing config pipeline).DebuggingSessionis 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)./rcconnection 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 reportsFailed(terminal-but-not-closed), neverDisposed.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 ✅
Given_HotReloadWorkspaceRegistry(eviction: oldest-first, keepsCapacityslots; unregister; idempotent register; live capacity-drop).This is an automatic backport of pull request #24240 done by [Mergify](https://mergify.com).