fix(web-incoming): defer pipe until socket connects#111
Conversation
Avoid piping request body into proxyReq before the underlying socket is connected. Piping eagerly can consume the request stream, causing body data loss when retrying the same request to an alternate target. Ref: http-party/node-http-proxy#1495
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #111 +/- ##
==========================================
+ Coverage 96.14% 97.36% +1.22%
==========================================
Files 8 8
Lines 623 684 +61
Branches 233 273 +40
==========================================
+ Hits 599 666 +67
+ Misses 24 18 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
pipe()of request body intoproxyRequntil the underlying socket is connected, preventing body data loss when the same request is retried against an alternate targetContext
Upstream PR: http-party/node-http-proxy#1495
When
pipe()is called before the socket connects, the request body stream is consumed eagerly. If the connection fails and the caller retriesproxy.web()with the samereqagainst a different target, the body has already been drained and is lost.The fix checks
socket.pendinginside thesocketevent — if pending, it waits forconnectbefore piping; if already connected (reused socket), it pipes immediately.The
forwardpath is left unchanged since it's fire-and-forget and doesn't have retry semantics.Test plan