fix(web-incoming): emit econnreset on client disconnect#115
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe ECONNRESET error handling in the stream proxy middleware was updated to check socket writability instead of destruction status. When connection reset occurs with a non-writable socket, the middleware emits an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #115 +/- ##
=======================================
Coverage 96.11% 96.11%
=======================================
Files 8 8
Lines 644 644
Branches 244 244
=======================================
Hits 619 619
Misses 24 24
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Check `!req.socket?.writable` instead of `req.socket.destroyed` in the proxy error handler. The socket `writable` flag is set to false earlier than `destroyed` during client disconnection, avoiding a race condition where ECONNRESET errors were incorrectly routed to the `error` event. Ref: http-party/node-http-proxy#1542
444b1db to
b12a68f
Compare
Summary
errorevent instead ofeconnresetreq.socket.destroyedcheck with!req.socket?.writablewhich is set earlier during socket teardownUpstream ref: http-party/node-http-proxy#1542
Detail
The
createErrorHandlerinweb-incoming.tschecks whether an ECONNRESET error is caused by a client disconnect. The original check (req.socket.destroyed) can befalseduring a timing race where the socket is closing but not yet fully destroyed. The upstream fix usedreq.aborted, but that property is deprecated since Node.js 17.This fix uses
!req.socket?.writableinstead, which:falsewhen the client has disconnected (socket closing/closed)truewhen the client is still connected (e.g. proxy timeout)req.socketisnullvia optional chainingTest plan
econnresetevent firesproxyTimeouttest still passes (timeout ECONNRESET correctly goes toerrorevent)Summary by CodeRabbit
Bug Fixes
Tests