Skip to content

[release/10.0.1xx] Fix ordering races in dotnet-watch BrowserTests - #57237

Merged
MiYanni merged 3 commits into
release/10.0.1xxfrom
miyanni-browser-diagnostics-hang-investigation
Nov 24, 2026
Merged

MiYanni merged 3 commits into
release/10.0.1xxfrom
miyanni-browser-diagnostics-hang-investigation

Conversation

@MiYanni

@MiYanni MiYanni commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

🤖Copilot🤖
Relates to #57235

Backports the BrowserTests.cs changes from #52897 and #53498, and the ApplyDeltaTests.cs changes from #52897. These are on main and release/10.0.4xx but never reached release/10.0.1xx. This change only touches test code.

Root cause

dotnet-watch writes its log messages to stderr, including ❌ ... error ENC0023 and Restart is needed. The ❔ Do you want to restart your app? prompt, the app's output, and the test browser's 🧪 Received lines go to stdout. AwaitableProcess merges both streams through two independent async readers, so the order between them isn't guaranteed.

WaitForOutputLineContaining takes 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 ❌ ENC0023 line. 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_TIMEOUT minus 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, BrowserDiagnostics passed. The work item failed because LaunchesBrowserOnStart hit the same kind of race: it asserted on the stderr Launching browser line after waiting only for the stdout Content root path: line.

ApplyDeltaTests had the same exposure: it used ordered waits and asserted on output already received, across both streams.

Changes

Validation

  • Ran build.cmd on release/10.0.1xx.
  • Ran dotnet test test\dotnet-watch.Tests\dotnet-watch.Tests.csproj locally 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, including AutoRestartOnRuntimeRudeEdit, BlazorWasm, BlazorWasmHosted, and MauiBlazor, 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.

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

Copy link
Copy Markdown
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.

@MiYanni
MiYanni marked this pull request as ready for review November 19, 2026 22:27
@MiYanni
MiYanni requested review from a team and tmat as code owners November 19, 2026 22:27
Copilot AI balanced review requested due to automatic review settings November 19, 2026 22:27

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.

🟢 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 BrowserDiagnostics with 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]>
@MiYanni

MiYanni commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

/azp run dotnet-sdk-public-ci

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@MiYanni
MiYanni enabled auto-merge November 23, 2026 21:31
@MiYanni
MiYanni merged commit 62c0409 into release/10.0.1xx Nov 24, 2026
28 checks passed
@MiYanni
MiYanni deleted the miyanni-browser-diagnostics-hang-investigation branch November 24, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants