Repository navigation
Retry the withdrawal of a discovery record that a reader holds open on Windows - #505
Conversation
…n Windows (#501) A reader that has the record open (discovery::list reads it with std::ifstream, which does not share deletion) made Registration::remove() fail with a sharing violation. The error was ignored, so a withdrawn session stayed listed while its process lived. This failed intermittently in CI on the Windows job, where the unit test polls list() every 10 ms while the controller withdraws the record.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 17 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
A moderate unresolved issue remains: the Windows removal retry logic conflicts with its documented intent by retrying all errors (potentially adding ~1s delay) instead of limiting retries to sharing/lock-violation cases.
1 open issue
What changed in this PR
This pull request fixes an intermittent Windows-specific issue where withdrawing an automation discovery record could fail due to a reader holding the record file open (sharing violation), leaving withdrawn sessions listed until the process exits. The change introduces Windows-only retry logic for record deletion and adds a regression test that simulates the locked-file scenario.
Changes:
- Add a Windows-specific
removeWithRetryhelper to retrystd::filesystem::removefor up to ~1 second (single attempt on POSIX). - Update
discovery::Registration::remove()to use the retry removal for both the record and its staged “.new” variant. - Add a unit/regression scenario that holds the record open briefly while withdrawal occurs.
Assessment: This pull request requires changes. (Retry should be limited to sharing/lock violations as intended; avoid path encoding loss when forming ".new"; reduce mutex hold time across filesystem I/O/sleep; and keep the Windows-only test delay guarded to avoid slowing POSIX runs.)
| File | Summary |
|---|---|
test/unit/AutomationDiscoveryTests.cpp |
Adds regression coverage for withdrawing a discovery record while it is held open by a reader (Windows sharing violation scenario). |
include/webfront/automation/Discovery.hpp |
Introduces Windows retry-based removal and wires it into Registration::remove() for record and staged “.new” cleanup. |
Review effort: Balanced
…until a steady_clock deadline (#506)

Closes #506. Follow-up of #501.
Problem
discovery::Registration::remove()ignored the error ofstd::filesystem::remove. On Windows, a reader that has the record open (discovery::listreads it withstd::ifstream, which does not share deletion) makes the removal fail with a sharing violation, and nothing retried: a withdrawn session stayed listed while its process lived.It fails intermittently on
desktop-native (windows-msvc-webview2): the scenario "A window that ignores the deadline's close request is declared unresponsive by the consumer's automation" pollslist()every 10 ms while the controller withdraws the record from another thread. Seen ondevelop(run 42609482904, merge of #502) and on the run 42611883578 of #503, which passed when rerun.Change
removeWithRetryretries the removal for up to one second on Windows (a single attempt on POSIX, where unlinking an open file succeeds). A regression scenario holds the record open and releases it after 100 ms; it only exercises the retry on Windows, where it fails without the change.Tests
Run locally on macOS: the new scenario, "A window that ignores the deadline's close request…" and "A shared session is listed…". The Windows job of this PR is the evidence for the fix.