Repository navigation
[release/10.0.1xx] Fix ordering races in dotnet-watch BrowserTests - #57237
Merged
MiYanni merged 3 commits intoNov 24, 2026
Merged
Conversation
dotnet-watch writes log messages to stderr while the rude-edit prompt and the app/test-browser output go to stdout. AwaitableProcess merges both streams through independent async readers, so line order across streams is not guaranteed. Ordered waits (WaitForOutputLineContaining) can consume a line before the test waits for it, which made BrowserDiagnostics wait forever for the restart prompt (#57235), and assertions on already-received output made LaunchesBrowserOnStart fail. Backports the BrowserTests changes from #52897 and #53498 on main. Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for this test-only backport addressing browser-test output-order races.
No open issues 🎉
What changed in this PR
Backports test reliability fixes from #52897 and #53498 to release/10.0.1xx, addressing dotnet-watch browser test races linked to #57235. Only test code changes.
Changes:
- Replace ordered output waits in
BrowserDiagnosticswith waits that tolerate stdout/stderr arrival order. - Wait for each expected startup and browser-launch message in
LaunchesBrowserOnStart, preserving the release branch’s two-argument message call.
| File | Description |
|---|---|
test/dotnet-watch.Tests/Browser/BrowserTests.cs |
Removes output-order assumptions from browser startup and hot-reload diagnostics tests. |
Review effort: Balanced
Backports the ApplyDeltaTests changes from #52897. These replace ordered WaitForOutputLineContaining calls, and AssertOutputContains/AssertOutputLineStartsWith calls on output already received, with WaitUntilOutputContains. dotnet-watch writes logs to stderr while prompts and app output go to stdout, so line order across the two streams is not guaranteed. Adapted to release/10.0.1xx message descriptors and expected output. #52897's un-skip of ProjectChange_DirectoryBuildProps_Delete (#49545) and its new MauiBlazor scoped-css steps are intentionally not included. Co-authored-by: Copilot App <[email protected]>
3 tasks
Member
Author
|
/azp run dotnet-sdk-public-ci |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
nagilson
approved these changes
Nov 20, 2026
Co-authored-by: Copilot App <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖Copilot🤖
Relates to #57235
Backports the
BrowserTests.cschanges from #52897 and #53498, and theApplyDeltaTests.cschanges from #52897. These are onmainandrelease/10.0.4xxbut never reachedrelease/10.0.1xx. This change only touches test code.Root cause
dotnet-watch writes its log messages to stderr, including
❌ ... error ENC0023andRestart is needed. The❔ Do you want to restart your app?prompt, the app's output, and the test browser's🧪 Receivedlines go to stdout.AwaitableProcessmerges both streams through two independent async readers, so the order between them isn't guaranteed.WaitForOutputLineContainingtakes lines off a single queue in arrival order. A line it takes while looking for something else can't satisfy a later wait. In the hang from #57235 (build 1690453, attempt 2), stdout delivered the restart prompt about 0.7s before the stderr❌ ENC0023line. The wait for the error line consumed the prompt, so the next wait for the prompt never matched. Meanwhile dotnet-watch sat at the prompt waiting for a key. The harness timeout (HELIX_WORK_ITEM_TIMEOUTminus 10s, about 1h) is longer than VSTest's 25-minute blame inactivity timeout, so blame killed the run first.In attempt 1 of the same build,
BrowserDiagnosticspassed. The work item failed becauseLaunchesBrowserOnStarthit the same kind of race: it asserted on the stderrLaunching browserline after waiting only for the stdoutContent root path:line.ApplyDeltaTestshad the same exposure: it used ordered waits and asserted on output already received, across both streams.Changes
BrowserDiagnostics: replace orderedWaitForOutputLineContainingcalls withWaitUntilOutputContains, as in [dotnet-watch] Misc test and product reliability fixes #52897.LaunchesBrowserOnStart: wait for each expected line instead of asserting on output already received, as in Fix output validation in LaunchesBrowserOnStart test #53498. This keeps the release branch's two-argumentLaunchingBrowser.GetMessagecall.ApplyDeltaTests(separate commit): 161 calls now useWaitUntilOutputContains: 63WaitForOutputLineContaining, 88AssertOutputContains, and 10AssertOutputLineStartsWith. It also adds [dotnet-watch] Misc test and product reliability fixes #52897's fourClearOutput()calls, so later waits can't match stale lines. InAutoRestartOnRuntimeRudeEdit, [dotnet-watch] Misc test and product reliability fixes #52897's four ordered waits for agent messages are kept; those lines all come from one stream, so their order is reliable. The changes are adapted to the messages and descriptorsrelease/10.0.1xxemits (for exampleHotReloadSucceededandHotReloadChangeHandledinstead ofmain'sManagedCodeChangesApplied/StaticAssetsChangesApplied).ProjectChange_DirectoryBuildProps_Delete(Change in DefineConstants should report rude edit and restart #49545) and its rewrite (it stays skipped and unchanged), the new MauiBlazor scoped-CSS steps, and a whitespace-only change.Validation
build.cmdonrelease/10.0.1xx.dotnet test test\dotnet-watch.Tests\dotnet-watch.Tests.csprojlocally on Windows, with TRX and binlog output:--filter "FullyQualifiedName~Microsoft.DotNet.Watch.UnitTests.BrowserTests": 5/5 passed.--filter "FullyQualifiedName~Microsoft.DotNet.Watch.UnitTests.ApplyDeltaTests": 30 passed, 9 skipped, 0 failed. The 9 tests were already skipped on this branch, includingAutoRestartOnRuntimeRudeEdit,BlazorWasm,BlazorWasmHosted, andMauiBlazor, so their edits are only compile-checked.These runs show the tests still pass with the change. Passing runs can't prove the races are gone, since they only show up on some runs.