fix(examples): redirect hook output to stderr in everything server#828
Conversation
All fmt.Printf calls in the hooks wrote to stdout, which is the JSON-RPC transport in stdio mode. When a tool handler sleeps (longRunningOperation), hook output interleaves with protocol framing and corrupts the connection. Redirected all hook output to os.Stderr. Hooks remain functional for debugging but no longer interfere with the stdio transport. Fixes mark3labs#826
|
Connected to Huly®: MCP_G-393 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughHook logging output in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
Summary
fmt.Printfcalls in the everything server's hooks wrote to stdoutlongRunningOperationtool'stime.Sleepcreates a timing window that makes this reliably reproducible, but any hook firing during a tool call can trigger itfmt.Fprintf(os.Stderr, ...)Test plan
go build ./examples/everything/passeslongRunningOperationno longer crashes the stdio transportFixes #826
Summary by CodeRabbit