Skip to content

fix(vfox): flush downloaded files before returning - #10833

Merged
jdx merged 1 commit into
mainfrom
codex/vfox-download-flush
Jul 7, 2026
Merged

jdx merged 1 commit into
mainfrom
codex/vfox-download-flush

Conversation

@jdx

@jdx jdx commented Jul 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • flush tokio::fs::File after write_all in http.download_file
  • return flush errors from http.try_download_file instead of reporting success before bytes are settled
  • addresses the test_try_download_file_success CI flake from the release PR where the file was read back as empty

Test

  • mise --cd crates/vfox run test test_try_download_file -- --nocapture
  • mise --cd crates/vfox run lint
  • mise --cd crates/vfox run test

This PR was generated by an AI coding assistant.


Note

Low Risk
Small, localized change to plugin download I/O with clearer error handling on flush; no auth or data-model impact.

Overview
Fixes a race where vfox plugin HTTP downloads could return before bytes were visible on disk, which showed up in CI as empty files right after a successful download.

download_file and try_download_file in crates/vfox/src/lua_mod/http.rs now call flush on the output file after write_all. try_download_file propagates flush failures as an error instead of reporting success.

Reviewed by Cursor Bugbot for commit 9c11a90. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Improved file download reliability by ensuring downloaded content is fully written to disk before reporting success.
    • Added proper error handling for write flush failures, so failed downloads now return an error instead of appearing successful.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 9ae10499-a66c-4581-9b5c-8cd85019f7aa

📥 Commits

Reviewing files that changed from the base of the PR and between e7ad2f1 and 9c11a90.

📒 Files selected for processing (1)
  • crates/vfox/src/lua_mod/http.rs

📝 Walkthrough

Walkthrough

Adds explicit file flush operations after write_all calls in two download functions within the Lua HTTP module, with corresponding error handling paths converted to Lua errors or nil/error tuples.

Changes

Download Flush Handling

Layer / File(s) Summary
Flush after write with error propagation
crates/vfox/src/lua_mod/http.rs
download_file flushes the file after write_all and converts flush errors into a Lua error; try_download_file flushes and returns (nil, err_string) on flush failure instead of returning success immediately.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

A rabbit writes, then pauses to flush,
No half-saved bytes left in a rush,
If errors appear, nil and a note,
Else success sails off, safely afloat. 🐇💾

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: flushing downloaded files before returning and surfacing flush errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a CI flake in the vfox backend where downloaded files were occasionally read back as empty. The root cause was that tokio::fs::File maintains an internal write buffer, and returning from the download functions without calling flush() could leave buffered bytes un-dispatched to the OS before the next read.

  • download_file: adds flush() after write_all(), propagating errors via into_lua_err()? like the rest of the function.
  • try_download_file: adds flush() with the same if let Err(e) error-return pattern used for every other fallible step in that function, correctly surfacing flush failures to Lua callers instead of silently returning success.

Confidence Score: 5/5

Minimal, targeted fix that closes a real data-availability gap; no logic is altered beyond ensuring writes are settled before returning.

The change adds two flush calls that were simply missing. Both follow the existing error-handling patterns in the file exactly, the new behavior is covered by the passing test suite, and there are no altered data paths or side effects outside the two functions.

No files require special attention.

Important Files Changed

Filename Overview
crates/vfox/src/lua_mod/http.rs Adds explicit flush() after write_all() in both download_file and try_download_file to ensure Tokio's internal write buffer is drained before the function returns; error handling for the flush in try_download_file follows the existing error-propagation pattern correctly.

Reviews (1): Last reviewed commit: "fix(vfox): flush downloaded files before..." | Re-trigger Greptile

@jdx
jdx enabled auto-merge (squash) July 7, 2026 13:17
@jdx
jdx disabled auto-merge July 7, 2026 13:22
@jdx
jdx enabled auto-merge (squash) July 7, 2026 13:23
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.7.1 x -- echo 24.0 ± 1.6 19.6 29.9 1.00
mise x -- echo 25.4 ± 3.3 20.8 83.7 1.06 ± 0.15

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.7.1 env 23.4 ± 1.6 20.5 28.8 1.00
mise env 24.3 ± 1.5 20.3 31.2 1.04 ± 0.09

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.7.1 hook-env 23.8 ± 1.1 20.6 29.8 1.00
mise hook-env 25.1 ± 1.5 21.0 31.2 1.05 ± 0.08

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.7.1 ls 19.9 ± 1.0 17.6 25.2 1.00
mise ls 20.6 ± 1.2 17.2 27.3 1.04 ± 0.08

xtasks/test/perf

Command mise-2026.7.1 mise Variance
install (cached) 187ms 190ms -1%
ls (cached) 70ms 71ms -1%
bin-paths (cached) 76ms 79ms -3%
task-ls (cached) 150ms 153ms -1%

@jdx
jdx merged commit 807fa69 into main Jul 7, 2026
35 checks passed
@jdx
jdx deleted the codex/vfox-download-flush branch July 7, 2026 13:26
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.

1 participant