fix(minimal): fix race when uploading to worktree - #806
Conversation
📝 WalkthroughWalkthrough
ChangesWorkspace upload error handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/minimal/src/client.rs`:
- Around line 222-228: Wrap the channel wait loop around channel.wait().await in
a timeout so stalled unpacking or an unclosed daemon channel cannot block
indefinitely. On timeout, drop the channel before returning or propagating the
timeout error, while preserving stderr collection and normal completion
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f6f05d99-f98d-4f99-b1a0-bd1a6b6be08b
📒 Files selected for processing (1)
crates/minimal/src/client.rs
| // Wait for the channel to close to signal that unpacking is done. | ||
| let mut err = Vec::new(); | ||
| while let Some(msg) = channel.wait().await { | ||
| if let russh::ChannelMsg::ExtendedData { data, ext: 1 } = msg { | ||
| err.extend_from_slice(&data); | ||
| } | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the relevant file around the cited lines
sed -n '180,260p' crates/minimal/src/client.rs | cat -n
# Find timeout-related policy references in the repo
rg -n "upload|ssh|timeout|deadline|Duration::from|tokio::time::timeout" crates -g '!target' -g '!node_modules'
# Find the channel wait / close pattern elsewhere
rg -n "channel\.wait\(\)\.await|ChannelMsg::ExtendedData|Wait for the channel to close" crates -g '!target' -g '!node_modules'Repository: gominimal/minimal
Length of output: 50373
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Look for upload-specific timeout constants/policy in the minimal client and nearby modules
rg -n "UPLOAD_TIMEOUT|upload.*timeout|timeout.*upload|SSH.*timeout|ssh.*timeout|deadline.*upload|workspace file upload" crates/minimal crates/minimald crates -g '!target' -g '!node_modules'
# Inspect the top of the client file for constants and surrounding guidance
sed -n '1,140p' crates/minimal/src/client.rs | cat -n
# Inspect the upload caller to see whether it already wraps this in a timeout
sed -n '960,1010p' crates/minimal/src/lib.rs | cat -nRepository: gominimal/minimal
Length of output: 8885
Bound the upload-completion wait. channel.wait().await can hang forever if unpacking stalls or the daemon never closes the channel; wrap this loop in a timeout and drop the channel on expiry.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/minimal/src/client.rs` around lines 222 - 228, Wrap the channel wait
loop around channel.wait().await in a timeout so stalled unpacking or an
unclosed daemon channel cannot block indefinitely. On timeout, drop the channel
before returning or propagating the timeout error, while preserving stderr
collection and normal completion behavior.
upload_workspace_filesdoes not wait for the daemon to be done unpacking, which can lead to races when test / CI code expects it all to be hunky dory. Fixes some flakes in CI.Summary by CodeRabbit