Skip to content

Hot reload: UpdateFile requests received before the workspace is initialized corrupt the delta baseline #23787

Closed

Description

@dr1rrb

Current behavior 🐛

On the dev-server, hot-reload file-update requests are processed the moment they arrive, without waiting for the Roslyn workspace to finish loading. Because the workspace captures its baseline by reading the solution from disk during (asynchronous) initialization, any UpdateFile request that lands before that read completes gets its edit written to disk first — so the baseline is loaded from the already-mutated file.

The consequence is a corrupted baseline: Roslyn diffs subsequent changes against a solution that already contains the early edit, so that edit is never emitted as a delta and the running application never receives it. The delta engine's baseline and the code the app was actually built from silently diverge, and from that point on hot-reload deltas can be computed against the wrong starting point.

Concretely, in Uno.UI.RemoteControl.Server.Processors/HotReload/ServerHotReloadProcessor:

  • ProcessUpdateFile(UpdateFileRequest) calls _fileUpdater.UpdateAsync(request, _ct.Token) immediately, with no dependency on the workspace being ready.
  • The workspace is created asynchronously in InitializeInner/InitializeAsync (kicked off from ProcessConfigureServer) and stored in the _workspace field. The baseline solution is loaded from disk in LoadSolutionFromDisk via CompilationWorkspaceProvider.CreateWorkspaceAsync.
  • FileUpdater.UpdateAsync edits the file (through the on-disk editor) with no gate against workspace readiness, so an update can be written to disk before — or while — the baseline is being read.

There is a BufferGate (_solutionWatchersGate) that batches file changes vs. the file-system watcher, but nothing gates update requests against the initial workspace load itself.

Expected behavior 🎯

UpdateFile requests received before the workspace has finished initializing (before HotReloadEvent.Ready) should be queued and applied only once the baseline solution has been captured, so the baseline always reflects the code the running application was built from. Edits should never be written to disk ahead of the initial baseline read.

How to reproduce it 🔬

This is a startup timing race, most easily hit when a client starts issuing UpdateFile requests at app startup, before the dev-server workspace has finished loading:

  1. Connect a client that sends one or more UpdateFileRequest frames very early — around the same time as (or right after) the ConfigureServer handshake, before the server has sent HotReloadWorkspaceLoadResult { WorkspaceInitialized = true } / notified HotReloadEvent.Ready.
  2. Observe that the edit is written to disk by FileUpdater before LoadSolutionFromDisk reads it.
  3. The subsequently loaded baseline already contains the edit, so no delta is produced for it and the running app never reflects the change.

This is primarily reproducible in QA/automation scenarios that drive updates programmatically at startup, but the race is valid in general — it is more likely to surface now that the design-time tooling begins issuing update requests as soon as the app starts.

Workaround 🛠️

Delay any programmatic UpdateFile request until after the client has received the workspace-initialized notification (HotReloadWorkspaceLoadResult.WorkspaceInitialized == true).

Suggested fix 💡

Gate ProcessUpdateFile on workspace readiness: await the _workspace initialization task (or a dedicated "ready" signal) before invoking _fileUpdater.UpdateAsync, queuing incoming requests until initialization completes. When Roslyn hot-reload is disabled (IDE-driven / no workspace), the current pass-through behavior should be preserved.

Anything else we need to know? 💬

No public API change is expected — the fix is internal to the dev-server hot-reload processor.

Activity

  1. added
    triage/untriaged
    on Jul 16, 2026
  2. added 2 commits that reference this issue on Jul 16, 2026
    c494b42
    a7520c3
  3. Jen-Uno commented on Sep 30, 2026

    @Jen-Uno
    Contributor

    QA: closing out without a manual pass. The fix in #23789 ships with automated tests (Given_WorkspaceGatedFileUpdater.cs) that exercise the change.

    If you still see this behaviour on a build that includes that PR, please reopen or comment here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions