Skip to content

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

Merged
agneszitte merged 9 commits into
release/stable/6.6from
mergify/bp/release/stable/6.6/pr-23649
Jul 6, 2026
Merged

agneszitte merged 9 commits into
release/stable/6.6from
mergify/bp/release/stable/6.6/pr-23649

Conversation

@mergify

@mergify mergify Bot commented Jul 6, 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 ✅


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

@agneszitte
agneszitte merged commit 0996723 into release/stable/6.6 Jul 6, 2026
10 of 11 checks passed
@agneszitte
agneszitte deleted the mergify/bp/release/stable/6.6/pr-23649 branch July 6, 2026 20:35
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.

2 participants