Skip to content

fix(broker): log the whole error chain when a worker fails to spawn - #1973

Merged
khaliqgant merged 2 commits into
mainfrom
fix/broker-spawn-error-chain
Oct 13, 2026
Merged

khaliqgant merged 2 commits into
mainfrom
fix/broker-spawn-error-chain

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Why

On fleet node sf-frame, claude spawns fail with only failed to spawn worker about 5ms after start (crates/broker/src/worker.rs:1670, command.spawn().context("failed to spawn worker")). Example from sf-frame.log.2026-10-12:

2026-10-12T21:41:45.003167Z ERROR relay_broker::runtime::relaycast_events: failed to spawn worker via relaycast WS child=e2e-d1fix-sfframe-1 error=failed to spawn worker

relaycast_events.rs logged the anyhow::Error with Display (%e), which prints only the outermost context. The OS error that explains the failure (for example No such file or directory) was dropped. The fleet action.result already uses {error:#}, but on that node those results are rejected with d1_pressure, so the log line is the only place the cause would appear.

Change

The log line and the eprintln! now use {:#}, through a spawn_failure_detail helper. This changes log output only. Behaviour is unchanged.

Verification

$ cargo test -p agent-relay-broker --lib spawn_failure_detail
test runtime::relaycast_events::tests::spawn_failure_detail_keeps_the_os_error ... ok
test result: ok. 1 passed; 0 failed; ...

Mutation check. I changed the helper to format!("{error}"):

test runtime::relaycast_events::tests::spawn_failure_detail_keeps_the_os_error ... FAILED
test result: FAILED. 0 passed; 1 failed; ...

After restoring it (cmp identical), the test passes again. cargo fmt --check and cargo clippy -p agent-relay-broker --lib -- -D warnings are clean.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff


Note

Low Risk
Logging-only change in one error path; no spawn, dispatch, or control-plane behavior is modified.

Overview
Relaycast WebSocket worker spawn failures now log the full anyhow error chain instead of only the outer context string failed to spawn worker.

The tracing::error! line and matching eprintln! in relaycast_events.rs go through a small spawn_failure_detail helper that formats with {:#}, so operators see underlying causes (for example a missing binary / NotFound) when fleet action results are unavailable. Spawn behavior and error propagation are unchanged.

CHANGELOG documents the fix under Fixed.

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


Agent Relay sessions

  • claude session a8232a06 · opened via gh pr create · last active 2026-10-13

On fleet node sf-frame, `claude` spawns end with "failed to spawn worker"
about 5ms after start. The log line formatted the anyhow error with
Display, which prints only the outermost context, so the OS error from
Command::spawn that says why the spawn failed was dropped.

Format it with `{:#}` through a small helper, and pin the helper with a
test that the io::Error survives.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T17:36:10.248013Z f9e81df PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d8d62890-12cb-4e56-9235-139bad969a65
📥 Commits

Reviewing files that changed from the base of the PR and between f9e81df and aca562f.

📒 Files selected for processing: 1
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes: 1
  • CHANGELOG.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

Broker worker spawn failures now log and print the full error chain, including underlying OS errors. A test checks for the spawn context and underlying error. The Unreleased changelog records the change.

Changes: Broker spawn error details

Layer / File(s) Summary
Format and report spawn error chains
crates/broker/src/runtime/relaycast_events.rs, CHANGELOG.md
A helper formats the full error chain for spawn failure output. A test checks that the formatted output includes the spawn context and underlying NotFound error. The changelog records the change.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to aca56

This change makes worker spawn-failure logs include the underlying OS error. It does not change runtime behavior, and no merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description explains the problem, change, and verification, but it does not use the required template sections. It omits the required Test Plan and RelayFlow Proof fields, including the change typ… Update the description to include Summary, Test Plan with completed test checkboxes, RelayFlow Proof with a valid change type and exactly one case or non-functional/n/a values, and Screenshots if applicable.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: logging the full error chain when a broker worker fails to spawn.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. (1 skipped: 1 …
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.
Full details: Description check

Explanation

The description explains the problem, change, and verification, but it does not use the required template sections. It omits the required Test Plan and RelayFlow Proof fields, including the change type and case.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • 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

A rabbit heard the worker fail,
And traced the error down the trail.
The OS clue came into view,
The log now prints the whole chain through.
Then tucked the changelog by the rail.

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

@capy-ai capy-ai Bot 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.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@capy-ai capy-ai Bot 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.

Capy found no issues.

Open in Capy

@khaliqgant
khaliqgant merged commit e279500 into main Oct 13, 2026
114 of 117 checks passed
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