Files
claude-hud/tests
xiangboit 9b491d09eb fix(usage-api): proxy CONNECT tunnel broken by premature socket return (#167)
* fix(usage-api): do not return socket from createConnection in proxy tunnel agent

Node.js _http_agent.js calls `oncreate(null, newSocket)` immediately
when createConnection returns a truthy value, which causes the HTTP
request to be written directly to the raw proxy socket before the
CONNECT handshake completes. Proxies like Clash reject this with
400 Bad Request, surfacing as persistent 403/network errors in the
Usage display.

Return undefined instead so the socket is only delivered via the
async callback after the CONNECT tunnel + TLS handshake succeeds.

Fixes proxy CONNECT failures with Clash and similar HTTP proxies.

* test(usage-api): cover proxy CONNECT request ordering

---------

Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-03-05 23:14:15 +11:00
..
2026-01-03 18:52:12 +11:00