Skip to content

fix(hr): report a compiler crash during the delta emit as a rude edit - #25420

Merged
kazo0 merged 7 commits into
masterfrom
dev/steve/hr-emit-rude-edit
Oct 14, 2026
Merged

kazo0 merged 7 commits into
masterfrom
dev/steve/hr-emit-rude-edit

Conversation

@kazo0

@kazo0 kazo0 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25418

PR Type:

🐞 Bugfix

What changed? 🚀

When Roslyn throws while emitting a Hot Reload delta, HotReloadManager completed the operation as InternalError through the pass's catch-all. The EnC baseline doesn't move, so every later edit hit the same crash and also reported InternalError until the app restarted. Nothing told the user that undoing the edit recovers. The current trigger is dotnet/roslyn#86045, which MVUX's generated code hits when a command's parameters change (MVUX workaround: unoplatform/uno.extensions#3227).

  • Exceptions from _watchService.EmitSolutionUpdateAsync only, except cancellation of the pass's token, now complete the pass as RudeEdit, with one synthesized diagnostic, UNOHR0001 ("Hot Reload update could not be emitted"). It is an Uno id because ENC ids belong to Roslyn. The message says how to recover:
    "The compiler could not produce a Hot Reload update for this change (). Undo the change to keep going, or restart the app."
  • The catch uses the filter Roslyn puts around its own CreateFromInternalError calls, where FatalError.ReportAndCatchUnlessCanceled lets an OperationCanceledException through only when the passed token is cancelled: catch (Exception e) when (e is not OperationCanceledException || !ct.IsCancellationRequested). A cancellation exception thrown by the emit while ct is not cancelled is a compiler failure like any other.
  • The full exception is logged at Warn, so compiler bugs stay visible in the log.
  • The rude-edit filter also accepts this diagnostic, next to the ENC ids, so it takes the existing rude-edit path: reporter, operation diagnostics, handler.
  • Exceptions anywhere else in the pass still end as InternalError.

Clients already treat RudeEdit as "this edit needs a restart", so IDEs and the App MCP react correctly without changes. The App MCP's wording for this case is in unoplatform/uno.app-mcp#203 and #204.

Test: Given_HotReloadManager.EmitFailure runs a real HotReloadManager over EnCHarness (the real Roslyn EnC pipeline, no stubbed emitter), with the code shape from dotnet/roslyn#86045:

  1. The crashing edit gives RudeEdit, a single UNOHR0001 diagnostic, no deltas, and the Warn log.
  2. Undoing it gives NoChanges.
  3. A valid edit gives Success with one delta.

It fails with InternalError before the fix. EnCHarness.CreateAsync gained optional baseline-source and extra-reference parameters; dynamic needs Microsoft.CSharp, System.Linq.Expressions and System.Runtime.

Verified end to end: I swapped this Uno.HotReload.dll into a 7.0.0-dev.2270 DevServer host; no commits touch src/Uno.HotReload between that build and this branch's base. I then ran the repro on a recommended-preset MVUX app on Skia desktop:

  1. Add a state: applied.
  2. Change the command's signature: RudeEdit with the diagnostic above. It used to be InternalError.
  3. Undo it: NoChanges.
  4. Edit the command's body: applied, and the new code runs.

Notes:

  • I built and ran the tests on net10.0 (-p:NetCurrent=net10.0 -p:NetPrevious=net9.0), because the machine has no .NET 11 SDK. Roslyn is 5.6.0 for both TFMs.

PR Checklist ✅

  • 🧪 Added tests (src/Uno.HotReload.Tests; that project: 148 passed, 1 skip that was already there)
  • 📚 Docs have been added/updated (UNOHR0001 in doc/articles/uno-build-error-codes.md, under a new Hot Reload Errors section; UNOHR added to the cSpell word list)
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes

🤖 Generated with Claude Code

https://claude.ai/code/session_01WjQPjTHecnxjgcqBhM8z3e

When Roslyn throws while emitting a Hot Reload delta (e.g. dotnet/roslyn#86045),
the pass fell into the manager's catch-all and completed as InternalError. The
EnC baseline does not move, so every later edit failed the same way until the
app restarted, with nothing telling the user that undoing the edit recovers.

Exceptions thrown by EmitSolutionUpdateAsync (cancellation excepted) now
complete the operation as RudeEdit with a synthesized UNOHR0001 diagnostic
asking the user to undo the change or restart the app. The full exception is
still logged at Warn level. Exceptions anywhere else in the pass stay
InternalError.

Fixes #25418

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WjQPjTHecnxjgcqBhM8z3e
Copilot AI balanced review requested due to automatic review settings October 14, 2026 02:35

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.

🔵 Needs a closer look

Correctness hinges on a non-obvious runtime EnC invariant (the baseline not advancing when the emit throws) in DevServer-critical Hot Reload infrastructure that cannot be fully verified by static inspection, so it warrants final human review.

0 open findings

What changed in this PR

This PR fixes issue #25418: when Roslyn throws while emitting a Hot Reload delta (e.g. dotnet/roslyn#86045, hit by MVUX generated code when a command's parameters change), HotReloadManager previously reported InternalError via the pass's catch-all. Because the EnC baseline never advances past the crashing edit, every subsequent edit also crashed and reported InternalError until app restart, with no guidance to the user. The fix narrowly wraps the EmitSolutionUpdateAsync call so a compiler emit exception is surfaced as a RudeEdit with a synthesized UNOHR0001 diagnostic — a state clients already handle as "this edit needs a restart" — while still logging the full exception at Warn and leaving all other exceptions as InternalError.

Changes:

  • Introduce a UNOHR0001 DiagnosticDescriptor and catch emit exceptions (excluding cancellation) around EmitSolutionUpdateAsync, converting them into a rude-edit diagnostic; extend the rude-edit filter to accept this descriptor alongside ENC* ids.
  • Extend EnCHarness.CreateAsync with optional appText and additionalReferences parameters so a baseline that triggers the real compiler crash (needing dynamic) can be set up.
  • Add Given_HotReloadManager.EmitFailure.cs, an end-to-end test over the real EnC pipeline asserting RudeEdit + single UNOHR0001 diagnostic + Warn log, NoChanges on undo, and Success on a later valid edit.
File Description
src/​Uno.HotReload/​HotReloadManager.cs Adds the UNOHR0001 descriptor, wraps the emit in try/catch to report compiler crashes as rude edits (re-throwing cancellation), and widens the rude-edit filter to keep this diagnostic.
src/​Uno.HotReload.Tests/​TestUtils/​EnCHarness.cs Adds optional baseline-source and extra-reference parameters so tests can configure the crash-reproducing compilation.
src/​Uno.HotReload.Tests/​Given_HotReloadManager.EmitFailure.cs New end-to-end test driving the real Roslyn EnC pipeline through the crash, undo, and recovery sequence.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Adds a Hot Reload Errors section to the error codes page: what the
diagnostic means, that undoing the change or restarting the app
recovers, and the known cause (dotnet/roslyn#86045). Adds UNOHR to the
cSpell word list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WjQPjTHecnxjgcqBhM8z3e
Copilot AI balanced review requested due to automatic review settings October 14, 2026 02:55
@github-actions github-actions Bot added area/build Categorizes an issue or PR as relevant to build infrastructure kind/documentation labels Oct 14, 2026

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.

🔵 Needs a closer look

It changes exception-classification semantics in the Hot Reload DevServer critical path and relies on reproducing a specific Roslyn compiler crash, which warrants final human review despite the solid test coverage.

0 open findings

🧠 Review effort: Balanced

kazo0 and others added 2 commits October 13, 2026 23:14
The emit failure now uses Roslyn's ENC1002 ("Cannot apply changes --
unexpected error"), which Roslyn itself uses for an internal error
treated as a blocking rude edit, so no Uno-specific id is needed.

This reverts commit a59b726.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WjQPjTHecnxjgcqBhM8z3e
Roslyn already has an id for this case: ENC1002 ("Cannot apply changes
-- unexpected error"), which EmitSolutionUpdateResults.CreateFromInternalError
uses for an internal error treated as a blocking rude edit. The
synthesized diagnostic now uses it, keeping the message that says how to
recover, and the rude-edit filter is back to accepting ENC ids only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WjQPjTHecnxjgcqBhM8z3e
Copilot AI balanced review requested due to automatic review settings October 14, 2026 03:15

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.

🟡 Changes recommended

The PR description makes several concrete claims (diagnostic id UNOHR0001, a modified rude-edit filter, and new docs/cSpell entries) that contradict the actual ENC1002-reuse implementation and should be reconciled.

1 open finding
Previously missed (1)

In code that hasn't changed since last review

Low severity PR description mismatches ENC1002 implementation

src/​Uno.HotReload/​HotReloadManager.cs:98

The implementation here diverges from the PR description. The description states the synthesized diagnostic id is UNOHR0001, that the rude-edit filter "also accepts this diagnostic" (implying a filter change), and that UNOHR0001 was documented in doc/articles/uno-build-error-codes.md with UNOHR added to the cSpell word list. In the actual change, the id is ENC1002 (reused from Roslyn so it passes the unchanged StartsWith("ENC") filter at line 339), the filter is untouched, and there is no UNOHR/ENC1002 documentation anywhere in the repo (verified: no UNOHR occurrences, no "Hot Reload Errors" section). The code appears self-consistent and correct; the PR description seems to describe an earlier approach. Please update the PR description to match the ENC1002-reuse implementation (and drop the UNOHR0001/docs/cSpell claims) so reviewers and release notes aren't misled.

🧠 Review effort: Balanced

Comment thread src/Uno.HotReload/HotReloadManager.cs Resolved
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 239379 has failed on Uno.UI - CI.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 14:17

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.

🔵 Needs a closer look

The change is small and I found no concrete defects, but it alters error-handling semantics in the sensitive Hot Reload / Roslyn EnC subsystem and its correctness depends on runtime EnC behavior that warrants human verification.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@kazo0

kazo0 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport servicing/6.8

@mergify

mergify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

backport servicing/6.8

✅ Backports have been created

Details

@unodevops

Copy link
Copy Markdown
Contributor

@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.

FYI: As far as I known, once the workspace as crashed you will have to recreate it (which is what a rude edit implies anyway)

Comment thread src/Uno.HotReload/HotReloadManager.cs Resolved
kazo0 and others added 2 commits October 14, 2026 12:35
ENC ids belong to Roslyn. The synthesized diagnostic goes back to an Uno
id, UNOHR0001, and the rude-edit filter accepts it alongside the ENC ids.

This reverts commit 855e34d.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0113rBQqDXVtD6eMXC8Eygn7
Restores the Hot Reload Errors entry for UNOHR0001 and the UNOHR cSpell
word.

This reverts commit 2d90b5b.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0113rBQqDXVtD6eMXC8Eygn7
Copilot AI balanced review requested due to automatic review settings October 14, 2026 16:40

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.

🔵 Needs a closer look

The fix hinges on subtle Roslyn EnC baseline semantics in the sensitive Hot Reload emit path and relies on a test exercising a real unfixed compiler bug, which warrants human sign-off even though no concrete issues were found.

0 open findings

🧠 Review effort: Balanced

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@mergify

mergify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@kazo0
kazo0 merged commit ec5e85c into master Oct 14, 2026
59 checks passed
@kazo0
kazo0 deleted the dev/steve/hr-emit-rude-edit branch October 14, 2026 18:45
@agneszitte

Copy link
Copy Markdown
Member

@Mergifyio backport release/stable/6.7

@mergify

mergify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.7

✅ Backports have been created

Details

agneszitte added a commit that referenced this pull request Nov 3, 2026
…6.7/pr-25420

fix(hr): report a compiler crash during the delta emit as a rude edit (backport #25420)
agneszitte added a commit that referenced this pull request Nov 3, 2026
…r-25420

fix(hr): report a compiler crash during the delta emit as a rude edit (backport #25420)
ajpinedam pushed a commit to ajpinedam/uno that referenced this pull request Nov 3, 2026
…ied (6.8, backport of unoplatform#24085)

Backport of unoplatform#24085 to servicing/6.8, on top of the
backport of unoplatform#25420 (unoplatform#25495),
which it builds on. Applies cleanly.

(cherry picked from commit 503b548)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Categorizes an issue or PR as relevant to build infrastructure kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HR][DevServer] A compiler crash while emitting a delta is reported as InternalError for every later edit; report it as a rude edit

5 participants