[release/9.0-staging] Fix Linux FileSystemWatcher silent stop after unpaired IN_MOVED_FROM - #134335
Conversation
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @dotnet/area-system-io |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused control-flow fix preserves watcher processing after stale-watch cleanup.
Review effort: Lite
Findings: None
What changed in this PR
Fixes a Linux FileSystemWatcher issue where an unmatched directory rename could permanently stop event processing.
Changes:
- Replaces an unintended method return with a loop break.
- Allows stale-watch cleanup and subsequent event processing to continue.
| File | Description |
|---|---|
src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Linux.cs |
Corrects control flow during unmatched directory rename handling. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
One or more custom setup steps configured for this repository failed during this Copilot code review run: Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review. Note You can configure setup steps for Copilot code review separately from Copilot cloud agent with a |
|
@adamsitnik - please check build analysis. |

Customer Impact
The customer built a version-control system on .NET and relies on
FileSystemWatcherto detect changes in users’ working trees.On Linux, a merge that moves directories on both sides can silently stop the watcher, disabling change detection for every workspace open in the process with no error or indication that the watcher has failed.
Expected: the watcher continues reporting changes or raises an Error so the application can recover.
Regression
Most likely Introduced by #9130 in .NET 9. It's not reproducible with .NET 11, because
FileSystemWatchergot rewritten.Testing
Verified using the customer-provided repro app from the issue.
No automated regression test was added because it would be flaky and since this component got rewritten in .NET 11, it's very unlikely for us to regress this code path in servicing branch.
Risk
Low. The change is a single-line, minimal-diff fix (
return false→break)confined to one
foreachloop inside the Linux inotify event-processing statemachine. It only affects the narrow error/cleanup path for an unmatched
IN_MOVED_FROMevent on a previously-watched subdirectory; the rest of thecontrol flow (watch removal, event dispatch, loop state reset) is unchanged.
Fixes #133420