fix(proxy): Node 24 / Electron 42 writeHead compat (interception fix)#113
fix(proxy): Node 24 / Electron 42 writeHead compat (interception fix)#113dinex-dev wants to merge 1 commit into
Conversation
|
Warning Review limit reached
More reviews will be available in 56 minutes and 2 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (3)
✨ 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 |
The vendored MITM eagerly called proxyToClientResponse.writeHead() when
upstream headers arrived, but the Requestly middleware buffers the whole body
and writes the FINAL (rule-modified) response itself in onResponseEnd. That is
two writeHead() calls: harmless on Node 18 (the later call overrode), but Node
24 (Electron 42) commits headers on the first writeHead and throws
ERR_HTTP_HEADERS_SENT ("Cannot write headers after they are sent") on the
second — an uncaught rejection that broke interception entirely.
- src/lib/proxy/lib/proxy.ts: skip the eager writeHead when response-end
handlers exist (the middleware is the authoritative writer); the eager headers
were also wrong, predating the rule modifications computed at response end.
- proxy-middleware + rule_action_processor: guard writeHead sites with
`!headersSent` so any residual double-write degrades to a safe no-op instead
of an uncaught Node-24 throw.
Prerequisite for the Electron 23->42 upgrade (desktop #358): without it the
upgraded app boots but cannot intercept traffic.
Verified on the Electron 42 desktop build: 25 writeHead errors -> 0; all
requests 200; proxy stable.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
88502a2 to
4ff76fa
Compare
commit: |
What
Makes the proxy's HTTP response handling safe on Node 24 (Electron 42). Prerequisite for the Electron 23→42 upgrade (desktop #358).
The bug
The vendored MITM eagerly calls
proxyToClientResponse.writeHead()when upstream headers arrive (proxy.ts). But the Requestly middleware buffers the whole body and writes the final, rule-modified response itself inonResponseEnd. That's twowriteHead()calls:writeHead, so the second throwsERR_HTTP_HEADERS_SENT("Cannot write headers after they are sent"). Uncaught → interception broke entirely on Electron 42 (app boots,Proxy Started, but every response errors).Fix
proxy.ts— skip the eagerwriteHeadwhen response-end handlers exist (the middleware is the authoritative writer). The eager headers were also wrong: they predate the rule modifications computed at response end.proxy-middleware/index.js,rule_action_processor/index.js— guard thewriteHeadsites with!headersSent, so any residual double-write degrades to a safe no-op rather than an uncaught Node-24 throw.Verified
On the Electron 42 desktop build, identical traffic burst: 25
writeHeaderrors → 0, all requests 200, proxy stable. Plain HTTPS, redirects, and 304s all pass.Scope
Separate from the RQ-2426 sandbox (#112) — different concern (Electron-42 transport compat vs. rule-code security). Both must land before publishing the proxy version that #358 bumps to.
🤖 Generated with Claude Code