Conversation
PR Review Squad — PR #283 Round 1CI Status: SummaryGood fix — preserves DevTunnel error message across 🟡 MODERATE
🟢 MINOR
Recommended Action:
|
When HostAsync() failed to start a tunnel, Stop() was called for cleanup which transitions state to NotStarted, clearing _errorMessage via SetState(). This caused the UI to flash back to the initial state with no error feedback — the user saw no QR code and no explanation. Fix: Save _errorMessage before Stop() and restore it via SetError() afterward so the Error state and message are visible to the user. Also fix the catch block to call Stop() before SetError() so the WsBridge started earlier in the method is properly cleaned up on unexpected exceptions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
add Assert.False(result) so the test always validates the failure path SetError(lastError ?? "DevTunnel failed to start") so failed HostAsync always ends in Error state even when TryHostTunnelAsync returns false without setting an error message Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f6bd3b7 to
45a5dad
Compare
Problem
When clicking "Start Dev Tunnels", the button briefly flashes a spinner then returns to its initial state with no error message — no QR code appears and no explanation is shown.
Root Cause
In
DevTunnelService.HostAsync(), whenTryHostTunnelAsync()fails (both initial and retry attempts),Stop()is called for cleanup at line 237.Stop()transitions throughStopping → NotStarted, andSetState(NotStarted)clears_errorMessage(since only theErrorstate preserves it). The error that was set bySetError()during the failed attempt is wiped before the UI can display it.The UI then shows the start button again (state =
NotStarted) instead of the error panel (state =Error).Fix
Stop(): Save_errorMessagebeforeStop(), then re-set it viaSetError()after cleanup so the user sees what went wrong.Stop()beforeSetError()in the catch block so the WsBridge started earlier in the method is properly cleaned up on unexpected exceptions.Tests Added
Stop_ClearsErrorMessage_ByDesign— confirms Stop() clears error (documents the root cause behavior)HostAsync_WhenTunnelFails_PreservesErrorMessage— end-to-end: verifies failed HostAsync ends in Error state with a messageErrorPreservation_SaveAndRestore_AcrossStop— tests the save/restore pattern used in the fixSetError_SetsStateToError_AndPreservesMessage— verifies SetError behaviorSetError_FiresOnStateChanged— verifies event firesAll 85 DevTunnel tests pass. All 1970 passing tests remain green (13 pre-existing PopupThemeTests failures unrelated).