fix: send BranchResult on failure to prevent channel orphaning#279
Merged
jamiepine merged 1 commit intospacedriveapp:mainfrom Mar 1, 2026
Merged
fix: send BranchResult on failure to prevent channel orphaning#279jamiepine merged 1 commit intospacedriveapp:mainfrom
jamiepine merged 1 commit intospacedriveapp:mainfrom
Conversation
When branch.run() returns an error, the spawned task only logged the failure but never sent a ProcessEvent::BranchResult back to the channel. This caused: 1. The branch ID to stay stuck in active_branches indefinitely (leaked) 2. The retrigger to never fire (should_retrigger stays false) 3. The channel LLM to never run again to deliver a reply 4. The metrics counter to never decrement Now the spawned task sends a BranchResult with the error as the conclusion on failure, matching how workers already handle this via WorkerComplete with notify: true.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
WalkthroughAdds error handling for spawned branch tasks by capturing task metadata (event_tx, agent_id, channel_id) before execution and sending a ProcessEvent::BranchResult with failure details when the branch task errors, ensuring failure notifications are reported to the channel. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
jamiepine
approved these changes
Mar 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
branch.run()returns an error, the spawned task logged the failure but never sent aProcessEvent::BranchResultback to the channel. This caused the channel to become permanently stuck:active_branchesindefinitely (leaked handle)should_retriggerstays false)The fix sends a
BranchResultwith the error as the conclusion on failure, matching how workers already handle this correctly viaWorkerCompletewithnotify: true.Root cause
In
channel_dispatch.rs, thetokio::spawnblock forbranch.run()only handledErrwith atracing::error!log — no event was sent. Meanwhile,branch.run()itself only sendsBranchResulton the success path (after the agentic loop breaks normally). Any hard failure (e.g. LLM API error, invalid model) fell through silently.Comparison with workers
Workers already handle this correctly — their spawn block matches on both
OkandErr, always settingnotify: true:Test plan
cargo clippy -- -D warningscleancargo fmt -- --checkcleanbranch.run()— no other spawn locations