fix: ensure PeerDisconnected is emitted on write-path disconnects#435
fix: ensure PeerDisconnected is emitted on write-path disconnects#435xdustinface merged 1 commit intov0.42-devfrom
PeerDisconnected is emitted on write-path disconnects#435Conversation
This fixes flaky failures in some of the integration tests coming soon. When a peer disconnects and the write path (broken pipe) detects it before the read path (EOF), the `PeerDisconnected` event could be lost entirely. `receive_message()` returned `ConnectionFailed` instead of `PeerDisconnected`, causing the reader loop to hit the catch-all error handler which slept 1 second before cleanup. During that sleep, the maintenance loop could silently remove the peer from the pool, preventing the event from ever being emitted. - Return `PeerDisconnected` from `receive_message()` when connection state is already cleared - Remove unnecessary 1-second sleep in the reader loop error handler
📝 WalkthroughWalkthroughNetwork peer error handling is refined by removing an unnecessary delay in the manager's error path and changing how missing internal reader state is reported in the peer module, aligning disconnection scenarios with a unified error type. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 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 |
This fixes flaky failures in some of the integration tests coming soon. When a peer disconnects and the write path (broken pipe) detects it before the read path (EOF), the
PeerDisconnectedevent could be lost entirely.receive_message()returnedConnectionFailedinstead ofPeerDisconnected, causing the reader loop to hit the catch-all error handler which slept 1 second before cleanup. During that sleep, the maintenanceloop could silently remove the peer from the pool, preventing the event from ever being emitted.
PeerDisconnectedfromreceive_message()when connection state is already clearedSummary by CodeRabbit