Repository navigation
fix(devserver): harden host startup against add-in crashes - #23649
Conversation
c2c8d1b to
811afd2
Compare
There was a problem hiding this comment.
Pull request overview
Hardens the Uno DevServer host startup path against add-in dependency/hosted-service failures so the host can still reach “ready” (keeping Hot Reload available) and the CLI can recover from early-start crashes.
Changes:
- Enhanced default ALC resolving to bridge already-loaded assemblies first, then attempt on-demand resolution from runtime/TPA or registered add-in directories.
- Introduced add-in hosted-service quarantine to contain constructor/StartAsync/background faults without failing host readiness.
- Added CLI “safe-mode” single-retry path (disable add-ins via sentinel) for hosts that die before readiness, plus test fixtures and regression coverage.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.UI.RemoteControl.Host/Helpers/HostAssemblyResolution.cs | Adds on-demand resolution + probing directory registration and miss reporting. |
| src/Uno.UI.RemoteControl.Host/Helpers/AssemblyHelper.cs | Registers add-in directories for probing; fixes structured logging argument ordering. |
| src/Uno.UI.RemoteControl.Host/Extensibility/AddInsExtensions.cs | Refactors add-in registration and applies hosted-service quarantine with telemetry callback. |
| src/Uno.UI.RemoteControl.Host/Extensibility/AddInHostedServiceQuarantine.cs | New quarantine wrapper for add-in IHostedService construction/start/background failures. |
| src/Uno.UI.RemoteControl.DevServer.Tests/Uno.UI.RemoteControl.DevServer.Tests.csproj | Links quarantine helper into tests; builds/stages new failing-hosted-service fixture. |
| src/Uno.UI.RemoteControl.DevServer.Tests/Given_HostAssemblyResolution.cs | Adds unit tests for on-demand runtime/TPA and probing-directory resolution behavior. |
| src/Uno.UI.RemoteControl.DevServer.Tests/Given_AddInHostedServiceQuarantine.cs | New unit tests validating quarantine behavior and boundaries. |
| src/Uno.UI.RemoteControl.DevServer.Tests/Fixtures/AddInWithFailingHostedService/Stub.cs | New add-in fixture that registers a hosted service with a throwing constructor + healthy sentinel. |
| src/Uno.UI.RemoteControl.DevServer.Tests/Fixtures/AddInWithFailingHostedService/AddInWithFailingHostedService.csproj | Fixture project targeting net9.0 for quarantine regression coverage. |
| src/Uno.UI.RemoteControl.DevServer.Tests/DevServerTests.cs | Integration tests for quarantine readiness and --addins ";" safe-mode sentinel. |
| src/Uno.UI.DevServer.Cli/StartCommandHandler.cs | Adds safe-mode retry decisioning and uses richer spawn result from process helper. |
| src/Uno.UI.DevServer.Cli/Helpers/DevServerProcessHelper.cs | Returns DirectSpawnResult with failure kind/exit code/stderr to enable safe-mode retry logic. |
| src/Uno.UI.DevServer.Cli.Tests/Mcp/Given_StartCommandHandler.cs | Updates tests for new spawn result type and adds safe-mode retry coverage. |
| src/Uno.UI.DevServer.Cli.Tests/Mcp/Given_StartCommandHandler_Integration.cs | Updates integration tests for new spawn result type. |
| src/SamplesApp/SamplesApp.Samples/Windows_UI_Xaml/FocusManager/ContentDialog_AutoFocusTextBox.xaml.cs | Adds a manual focus/keyboard behavior sample (scope unrelated to DevServer changes). |
| src/SamplesApp/SamplesApp.Samples/Windows_UI_Xaml/FocusManager/ContentDialog_AutoFocusTextBox.xaml | XAML UI for the new manual sample. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23649/wasm-skia-net9/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23649/wasm-skia-net9/index.html |
Co-authored-by: David <[email protected]>
Co-authored-by: David <[email protected]>
|
@Mergifyio backport release/stable/6.6 |
✅ Backports have been createdDetails
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23649/wasm-skia-net9/index.html |
…6.6/pr-23649 fix(devserver): harden host startup against add-in crashes (backport #23649)
GitHub Issue: unoplatform/uno-private#1968 (parent tracking issue — left open for QA validation and the IDE-extension slices unoplatform/uno.studio#1027 / unoplatform/uno.rider#489)
PR Type:
🐞 Bugfix
What changed? 🚀
On .NET 9-only machines, the DevServer host dies before becoming ready with
FileNotFoundException: System.Text.Encodings.Web, Version=8.0.0.0raised from the licensing client (Kiota) that the Settings add-in registers as a hosted service, and the launcher restarts it in a loop (~40× in the QA logs). The IDE-side dnx→global-tool fallback works; the remaining failure is inside the host process.This PR makes the DevServer resilient to that whole failure class, in three independent layers:
On-demand assembly resolution (
HostAssemblyResolution): theDefault.Resolvingbridge previously only returned already-loaded assemblies, making it load-order dependent (System.Text.Encodings.Webis neither in the host folder nor guaranteed loaded). On a miss the handler now attempts a version-less runtime/TPA load (with a re-entrancy guard) and then probes the registered add-in directories, both behind the same PublicKeyToken / no-downgrade guards as the bridge. Miss diagnostics are emitted only when everything failed, and satellite.resourcesmisses stay silent.Add-in hosted-service quarantine (
AddInHostedServiceQuarantine): add-inIHostedServiceregistrations are wrapped so construction is deferred out of ASP.NET Core's eagerIEnumerable<IHostedService>materialization; constructor/StartAsync failures are logged (with a telemetry eventaddin-hosted-service-quarantined) and disable that service only — the host still becomes ready and Hot Reload keeps working. Faulted add-inBackgroundServiceexecutions are observed instead of stopping the host. The host's own hosted services keep fail-fast behavior.CLI safe-mode retry (
StartCommandHandler): when the spawned host dies before readiness and add-ins were in play, the CLI retries exactly once with--addins ";"— a value every shipped host version interprets as "zero add-ins, skip MSBuild discovery" — turning the silent crash-restart loop into one clearly-logged degraded-mode start that surfaces the captured host stderr.Also fixes a pre-existing structured-logging argument-order bug in
AssemblyHelper.ReportAssemblyRefMismatchesthat printed the version/PKT/name of the mismatch warning shuffled.Validation (all runtime, macOS):
AddInWithFailingHostedServicereproduces the exact crash shape; fail-before/pass-after proven — with quarantine disabled the host dies before ready (QA failure), with it the host reaches ready and still starts the add-in's healthy services.--addins ";"safe-mode sentinel.Note: a clean .NET 9 runtime resolves the 8.0.0.0 request via framework unification in isolation, so the exact environmental trigger on the QA machines is still being pinned down (QA has been asked for
dotnet --info/project.assets.json); the layers above are deliberately trigger-independent. Backport torelease/stable/6.6is planned only after this merges and QA validates. A follow-up in uno.settings to align the Kiota/System.Text.Encodings.Webreferences is tracked separately.PR Checklist ✅
Screenshots Compare Test Runresults.