Repository navigation
fix(hr): gate UpdateFile requests on workspace initialization (spec 050) - #23789
Conversation
|
Claude finished @dr1rrb's task in 2m 53s —— View job Review complete
SummaryThis is a clean, well-grounded spec. The problem statement is precise (two named failure windows with distinct mechanisms), the state machine is well-scoped, and the decorator pattern correctly separates gating policy from the processor. The fact table (F1–F9) is a strong anchoring device — it makes the design legible without access to the source. 3 findings posted as inline comments:
No blocking issues — the spec is correct as a whole and the design decisions are sound. The three findings are clarifications that will prevent implementation divergence; they're all additive (nothing to remove). |
There was a problem hiding this comment.
Pull request overview
Adds a new design spec (spec 050) to document and propose a fix for hot-reload UpdateFile requests racing Roslyn workspace initialization on the dev-server, causing baseline corruption or missed change detection.
Changes:
- Introduces spec 050 describing the two race windows and their impact on deltas/baseline correctness.
- Defines a per-connection workspace lifecycle state machine and per-state request handling (queue/flush/pass-through/fail-fast).
- Proposes implementing gating as a
WorkspaceGatedFileUpdaterdecorator with a server-side queue TTL and a concrete test plan.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Claude finished @dr1rrb's task in 7m 51s —— View job Review complete
SummaryVerdict: fix-first — the state machine, cancellation design, FIFO ordering, and sticky-terminal logic are all correct. Four findings posted as inline comments; the first three share the same root cause and should be addressed together before merge. 4 findings (1 pattern × 3 occurrences, 1 thread-safety):
Cross-cutting notes (no blocking issues):
Test coverage is solid: the 13 unit tests cover the major state-machine paths, FIFO ordering, TTL expiry, cancellation, and the |
|
Claude finished @dr1rrb's task in 5m 34s —— View job Review complete
SummaryThe design and state machine are clean: the 3 findings posted as inline comments, all in
No architectural or SOLID concerns. The separation of |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23789/wasm-skia-net9/index.html |
|
Claude finished @dr1rrb's task in 5m 15s —— View job Review complete
SummaryVerdict: ship — all prior blocking and moderate findings have been fully addressed. Two minor issues posted as inline comments; neither blocks merge. Prior findings — all addressed:
Two new regression tests added alongside the fixes: 2 minor inline findings posted:
One theoretical edge case noted (not posted inline): if The state machine, FIFO ordering, |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23789/wasm-skia-net9/index.html |
…ts baseline An update request racing the async workspace initialization was written to disk before the baseline solution was read, folding the edit into the baseline (never emitted as a delta) or landing before the FileSystemObserver existed (never observed). Requests are now gated on the workspace lifecycle by a WorkspaceGatedFileUpdater decorator: queued while initializing, flushed FIFO once the baseline is captured and the observer is active, pass-through when hot reload is IDE-driven (no workspace), failed with an explicit error on init failure/dispose or after a hard 30s queue timeout (configurable via the update-file-queue-timeout server configuration). Implements specs/050-hotreload-updatefile-workspace-gate; fixes #23787.
Harden WorkspaceGatedFileUpdater against a throwing diagnostics callback: complete each queued entry before invoking reporter/onEvent, guard those callbacks, and give DrainAsync an outer try/finally that always resets the draining flag (catching + logging any unexpected escape). WatchTimeoutAsync now guarantees the entry is resolved on any fault, _inner is volatile, and timed-out/cancelled entries are compacted out of the queue so a workspace stuck in Initializing cannot grow it unbounded. Adds two regression tests. Spec 050: add the standard header, drop the broken 049 link, use stable symbol references instead of file:line, draw the NoWorkspace -> Initializing edge, reword R2 (flush point is not today's Notify(Ready)), state TTL is timer-based, and add the mode-change test-plan item.
DrainAsync: reset _draining atomically with the empty-queue check under the same lock (removing the finally) so a request arriving in Ready state can no longer observe an empty queue with draining still latched and get stuck unflushed; the catch path also resets it under the lock on an unexpected escape. Re-check the lifecycle immediately before applying so an entry already dequeued when the workspace goes terminal (Failed/Disposed) is rejected rather than written to disk. Reject: guard against a default ImmutableArray (Select would throw NRE), matching FileUpdater's IsDefaultOrEmpty entry guard. ServerHotReloadProcessor: drop the dead `?? ex?.ToString()` (Message is never null on a non-null exception).
UpdateAsync: arm the TTL watcher (WatchTimeoutAsync) outside the _gate lock. If the token is already cancelled or the timeout is zero, the watcher runs synchronously through its finally -> CompactQueue, which re-enters _gate; starting it under the held lock ran that re-entrant queue mutation mid-enqueue. ServerHotReloadProcessor: in IDE-driven mode, report NoWorkspace before awaiting Notify(Ready) so an UpdateFile racing that window passes through immediately instead of being queued (strict IDE-driven pass-through).
82d84b5 to
b9e4e6e
Compare
|
Claude finished @dr1rrb's task in 6m 1s —— View job Review complete
SummaryVerdict: ship — all prior blocking and moderate findings from rounds 1–3 are correctly addressed. Three minor findings posted as inline comments; none blocks merge. Prior findings — all confirmed addressed in this push:
Correctness of fixes verified by inspection:
3 minor inline findings posted:
Test coverage: 15 unit tests cover all major state-machine paths, FIFO ordering, TTL expiry, cancellation, drain exception safety, queue compaction, and the |
UpdateAsync re-checks the workspace lifecycle immediately before the pass-through call to the inner updater: a terminal transition (Failed/Disposed) reported from the init task or Dispose can race the pass-through decision made under the lock, so re-check and reject without applying (mirrors the same re-check already on the drain path).
|
Claude finished @dr1rrb's task in 3m 29s —— View job Review complete
SummaryVerdict: ship — the latest commit ( Latest fix verified by inspection: The new double-checked lock in Two minor findings posted as inline comments (same as prior round — still open):
Neither blocks merge. The state machine, FIFO ordering, |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/Uno.HotReload/IO/WorkspaceGatedFileUpdater.cs:56
queueTimeoutis accepted without validation. If a negative value is passed,Task.Delay(QueueTimeout, ...)will throw at runtime and callers will get an opaque rejection message derived fromArgumentOutOfRangeException.Messagerather than a clear argument error. Since this is a public type, validatequeueTimeoutat construction time (e.g., reject< TimeSpan.Zero).
/// <summary>
/// Max delay a request is kept queued while waiting for the workspace to become ready.
/// On expiry the request is failed and is never applied afterwards.
/// </summary>
public TimeSpan QueueTimeout { get; } = queueTimeout ?? DefaultQueueTimeout;
GitHub Issue: closes #23787
PR Type:
🐞 Bugfix
What changed? 🚀
The dev-server processed hot-reload
UpdateFilerequests the moment they arrived, with no dependency on the Roslyn workspace initialization. Since the workspace captures its baseline by reading the solution from disk asynchronously, an update request racing that read was written to disk first — the baseline silently absorbed the edit and it was never emitted as a delta (the running app permanently diverges from the delta engine's baseline until rebuild). A second window existed where the edit landed after the baseline read but before theFileSystemObserverwas created, so it was never observed at all. Both windows produce "request acknowledged, change never applied" — most easily hit by design-time tooling issuing updates at application startup.This PR contains the design spec (
specs/050-hotreload-updatefile-workspace-gate/spec.md, marked implemented with implementation notes) and its implementation:IFileUpdater(new,Uno.HotReload/IO): contract extracted fromFileUpdaterso behavior composes by decoration; the bareFileUpdaterkeeps its exact semantics for consumers without a Roslyn workspace.WorkspaceGatedFileUpdater(new): decorator holding the whole state machine, driven byHotReloadWorkspaceState(NotConfigured / NoWorkspace / Initializing / Ready / Failed / Disposed):update-file-queue-timeoutserver configuration) — an expired request is never applied late;Results(FileUpdateResult.NotAvailable) so clients don't mistake them for an empty "no changes" success;queued/flushed/expired/rejected) relayed asupdate-*telemetry.ServerHotReloadProcessor: stays a thin message router — it only composes the decorator and reports lifecycle transitions (Initializingbefore the workspace load,Readyafter theFileSystemObserveris constructed,Failedon init failure,Disposedon dispose,NoWorkspacein IDE-driven mode).ProcessUpdateFileis unchanged; repeatedConfigureServermessages only swap the decorated editor, the gate (state + queued requests) survives.Both message shapes (
UpdateFileRequestand the legacyUpdateSingleFileRequest) funnel through the same updater call, so the gate covers them uniformly.Testing
Uno.HotReload.Tests/IO/Given_WorkspaceGatedFileUpdater.cs) covering the state machine in isolation: queue-then-flush ordering, pre-configuration queueing, VS pass-through, workspace failure, sticky terminal states, TTL expiry (incl. no late application), expired entries not blocking live ones, dispose with a non-empty queue,NoWorkspace → Initializingreconfiguration without replay, inner swap while queued, cancellation, gate events. All 87 tests of the project pass.Uno.UI.RemoteControl.DevServer.Tests): 481 passed / 0 failed (2 pre-existing skips).PR Checklist ✅
Screenshots Compare Test Runresults.