Skip to content

fix(devserver): harden host startup against add-in crashes - #23649

Merged
ajpinedam merged 9 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/dev.server.fallback
Jul 6, 2026
Merged

ajpinedam merged 9 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/dev.server.fallback

Conversation

@ajpinedam

@ajpinedam ajpinedam commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

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.0 raised 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:

  1. On-demand assembly resolution (HostAssemblyResolution): the Default.Resolving bridge previously only returned already-loaded assemblies, making it load-order dependent (System.Text.Encodings.Web is 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 .resources misses stay silent.

  2. Add-in hosted-service quarantine (AddInHostedServiceQuarantine): add-in IHostedService registrations are wrapped so construction is deferred out of ASP.NET Core's eager IEnumerable<IHostedService> materialization; constructor/StartAsync failures are logged (with a telemetry event addin-hosted-service-quarantined) and disable that service only — the host still becomes ready and Hot Reload keeps working. Faulted add-in BackgroundService executions are observed instead of stopping the host. The host's own hosted services keep fail-fast behavior.

  3. 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.ReportAssemblyRefMismatches that printed the version/PKT/name of the mismatch warning shuffled.

Validation (all runtime, macOS):

  • New fixture AddInWithFailingHostedService reproduces 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.
  • New integration test boots a real host with the --addins ";" safe-mode sentinel.
  • Live smoke: the net9.0 host (built from this branch, overlaid into the NuGet cache) running on runtime 9.0.9 quarantined the crashing add-in and reached ready.
  • Full DevServer + CLI test suites pass; the only failures are pre-existing on master (verified by stash-run on the clean baseline).

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 to release/stable/6.6 is planned only after this merges and QA validates. A follow-up in uno.settings to align the Kiota/System.Text.Encodings.Web references is tracked separately.

PR Checklist ✅

Copilot AI review requested due to automatic review settings July 4, 2026 21:03
@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Jul 4, 2026
@ajpinedam
ajpinedam force-pushed the dev/anpi/dev.server.fallback branch from c2c8d1b to 811afd2 Compare July 4, 2026 21:06

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

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.

Copilot AI review requested due to automatic review settings July 4, 2026 21:07

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 14 out of 14 changed files in this pull request and generated no new comments.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings July 6, 2026 17:59

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 14 out of 14 changed files in this pull request and generated 1 comment.

@unoplatform unoplatform deleted a comment from mergify Bot Jul 6, 2026
@agneszitte

Copy link
Copy Markdown
Member

@Mergifyio backport release/stable/6.6

@mergify

mergify Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.6

✅ Backports have been created

Details

@unodevops

Copy link
Copy Markdown
Contributor

@ajpinedam
ajpinedam merged commit 9d3087e into unoplatform:master Jul 6, 2026
65 checks passed
agneszitte added a commit that referenced this pull request Jul 6, 2026
…6.6/pr-23649

fix(devserver): harden host startup against add-in crashes (backport #23649)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants