TCP socket upgrade never completes TLS handshake

I'm opening a TCP socket and then performing a TLS handshake. I am trying to await the opened promise, but it gets canceled in wrangler and hangs in production.

Surprisingly enough, if I don't await the opened promise, then it works as expected, but only during wrangler dev! In production, if I omit awaiting on opened, then I get an error that the handshake failed as soon as I try to read from the secure socket.

In this example I'm proxying through webshare to reach www.google.com. I've confirmed that it works over a basic curl. Any idea what I'm doing wrong? Thanks!
CleanShot_2024-12-02_at_22.24.432x.png
Cloudflare Docs
Use the connect() API to create outbound TCP connections from Workers.
Was this page helpful?