Skip to content

fix(adapters): close the download-wait race against a fast finish - #492

Open
HappyDevs1 wants to merge 1 commit into
mainfrom
fix/489-download-wait-race
Open

fix(adapters): close the download-wait race against a fast finish#492
HappyDevs1 wants to merge 1 commit into
mainfrom
fix/489-download-wait-race

Conversation

@HappyDevs1

Copy link
Copy Markdown
Collaborator

Summary

  • wait_for_download (crates/flowproof-adapters/src/web.rs) snapshotted "what's already there" fresh, at call time, inside the function. A download that finished (and dropped .crdownload) in the gap between the triggering step and the later Wait until the download completes as <name> step actually invoking wait_for_download was already sitting in that baseline — never seen as new, spinning the step to its full timeout and reporting failure despite a real, successful download.
  • The baseline now lives on WebAppDriver as claimed_downloads, snapshotted once at launch (before any step runs), and grows by one entry each time a call successfully matches a file. This closes the race for fast/small exports while keeping the existing "second call gets the second file" sequential-download contract from feat(driver): pin browser downloads and wait for one to land #483.
  • Extracted the "which files count as new" comparison into a pure, unit-testable unclaimed_downloads() — no live browser needed to prove the diff logic.

Test plan

  • cargo test -p flowproof-adapters --features web — 20/20 tests pass, including 5 new: the race case itself (file_present_but_never_claimed_is_new), already-claimed exclusion, sequential second-call, empty input, multiple-at-once.
  • cargo fmt --check
  • cargo clippy -p flowproof-adapters --features web --all-targets -- -D warnings

Per scope agreed at plan time, no live-Chrome integration test was built for this — the unit tests prove the comparison logic; they can't prove the fix against a real browser end-to-end.

Fixes #489

🤖 Generated with Claude Code

wait_for_download snapshotted "what's already there" fresh at call
time, so a download that finished (and dropped .crdownload) before
the wait step was actually dispatched was already in that baseline —
never seen as new, spinning the step to a timeout despite a real,
successful download.

The baseline now lives on the driver, snapshotted once at launch
before any step runs, and grows by one entry each time a call
matches — closing the race while keeping the existing "second call
gets the second file" sequential-download contract from #483.

Fixes #489
Copilot AI lite review requested due to automatic review settings August 18, 2026 11:26

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

web: wait_for_download's new-file baseline can miss a download that lands before the wait step runs

2 participants