Skip to content

Retry the withdrawal of a discovery record that a reader holds open on Windows - #505

Merged
AM-L merged 2 commits into
developfrom
fix-discovery-record-removal-windows
Nov 9, 2026
Merged

AM-L merged 2 commits into
developfrom
fix-discovery-record-removal-windows

Conversation

@ambroise-leclerc

@ambroise-leclerc ambroise-leclerc commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #506. Follow-up of #501.

Problem

discovery::Registration::remove() ignored the error of std::filesystem::remove. On Windows, a reader that has the record open (discovery::list reads it with std::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" polls list() every 10 ms while the controller withdraws the record from another thread. Seen on develop (run 42609482904, merge of #502) and on the run 42611883578 of #503, which passed when rerun.

Change

removeWithRetry retries 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.

…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.
Copilot AI balanced review requested due to automatic review settings November 9, 2026 12:17
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1d2c92aa-3c20-4866-b651-83f8e6d1f095
Commits

Reviewing files that changed from the base of the PR and between 6eb8293 and 46c42f0.

Files selected for processing: 2

  • include/webfront/automation/Discovery.hpp
  • test/unit/AutomationDiscoveryTests.cpp
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 removeWithRetry helper to retry std::filesystem::remove for 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

@AM-L
AM-L merged commit 63848a8 into develop Nov 9, 2026
9 checks passed
@AM-L
AM-L deleted the fix-discovery-record-removal-windows branch November 9, 2026 13:09
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.

Windows: the withdrawal of a discovery record can fail while a reader holds it, leaving a dead session listed

3 participants