Skip to content

Fix dotnet-watch dependency output races - #55618

Merged
JeremyKuhne merged 2 commits into
dotnet:mainfrom
JeremyKuhne:fix-watch-package-resolution-race
Aug 6, 2026
Merged

JeremyKuhne merged 2 commits into
dotnet:mainfrom
JeremyKuhne:fix-watch-package-resolution-race

Conversation

@JeremyKuhne

@JeremyKuhne JeremyKuhne commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Fix timing races in the dotnet-watch project- and package-reference update tests.

The tests wait for application output and then immediately inspect a concurrently populated process-output list for the dependency resolver diagnostic. Application stdout can be delivered before the resolver diagnostic from the other redirected stream, even though resolution completed successfully. This caused ProjectAndSourceFileChange_AddPackageReference to fail intermittently on macOS arm64; the CI log showed the expected diagnostic arriving during teardown immediately after the assertion.

Register completion signals for the resolver diagnostics before starting watch and await them directly using the watcher's shutdown token. Apply the same fix to the project-reference variant tracked by #53661.

Fixes #53661

Validation

  • dotnet-watch.Tests builds successfully.
  • ProjectAndSourceFileChange_AddPackageReference: passed.
  • Package- and project-reference variants: 5 iterations, 10/10 passed using fresh scratch directories.
  • Complete ProjectUpdateInProcTests class: 3/3 passed after the review update.

Copilot AI review requested due to automatic review settings August 5, 2026 20:47
@JeremyKuhne
JeremyKuhne requested review from a team and tmat as code owners August 5, 2026 20:47
@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.

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.

Pull request overview

This PR hardens dotnet-watch in-proc Hot Reload tests against output ordering races by waiting on a dedicated completion signal for the dependency-resolution diagnostic instead of inspecting a concurrently appended output buffer.

Changes:

  • Added a hasResolvedDependency completion source in both project- and package-reference update tests, set from OnProcessOutput when the expected “Resolving …” diagnostic is observed.
  • Replaced the post-output ProcessOutput substring assertion with an explicit WaitAsync bounded by a 30-second cancellation token.

@JeremyKuhne
JeremyKuhne enabled auto-merge (squash) August 5, 2026 21:07

@tmat tmat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing.

@JeremyKuhne
JeremyKuhne merged commit 3a169f6 into dotnet:main Aug 6, 2026
27 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Aug 7, 2026
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.

[Known Build Error] ProjectUpdateInProcTests.ProjectAndSourceFileChange_AddProjectReference timing failure

3 participants