Skip to content
Commit Detail

Commit 258bbb9

Author
Matt Alonso <malonso@cloudflare.com> 2026-04-23 12:17:58 -0500
Parents
74ad743
Tree
76f9d95
fix: populate localAddress on connect handler Socket

ServiceWorkerGlobalScope::connect was dropping the CONNECT authority when
constructing the ingress Socket, causing both socket.opened.remoteAddress
and socket.opened.localAddress to resolve to undefined on the connect
handler side. Plumb a localAddress parameter through Socket/setupSocket
and forward the host parameter into it so JS callers see the exact
authority string that was passed to fetcher.connect(...).

From the handler's perspective the CONNECT authority is the local address
on this side of the tunnel (the address the peer asked to connect to),
not the remote address, so populate localAddress rather than
remoteAddress. Outbound sockets continue to populate remoteAddress as
before; localAddress remains empty for outbound since we have no useful
value to expose.

Extend the existing connect-handler-test with a localAddressViaServiceBinding
case that asserts strict equality between the authority passed to
fetcher.connect(...) and the localAddress observed on the server side.

Files changed