Claude Opus 5.5

wrangler-4-125-0-19-b

Claude Code's read-only tools, web search on, ludion sync off

Question

What is the connect handler in a Worker, and how do I configure it in wrangler?

Answer key

A correct answer says
A `connect` config entry (e.g. `"connect": [{ "protocol": "tcp", "port": 5432 }]`) lets a Worker receive raw socket connections in its `connect(socket, env, ctx)` handler during local development (wrangler dev / Vite plugin): TCP since 4.125.0, and UDP (`protocol: "udp"`) since 4.139.0. It is experimental and local-only; deployed Workers cannot yet accept inbound sockets.
The stale answer
Workers can only receive HTTP requests; inbound raw TCP sockets are not possible.

The change's lesson

Answer

The `connect` handler is a newer Worker entry point that receives **inbound raw TCP connections**. You export `connect(socket, env, ctx)` alongside or instead of `fetch`, and the Worker reads and writes the socket directly. A third-party write-up says it was announced in private beta. Don't confuse it with `connect()` from `cloudflare:sockets`, which opens *outbound* TCP connections.

According to the wrangler 4.125.0 release notes, you configure it with a `connect` trigger in your wrangler config, for example `"connect": [{ "protocol": "tcp", "port": 5432 }]`. Only `"tcp"` is supported for now, and you also need an experimental compatibility flag. In `wrangler dev`, each entry opens a listening socket (on 127.0.0.1 by default) and sends connections straight to your handler, skipping the HTTP entry point. I couldn't find official Cloudflare docs that give the exact flag name or explain how the trigger works in production deployments, so check the Wrangler configuration docs before relying on it.

Sources:
- [wrangler@4.125.0 release notes](https://newreleases.io/project/github/cloudflare/workers-sdk/release/wrangler@4.125.0)
- [Cloudflare Workers inbound TCP/gRPC (developersdigest)](https://www.developersdigest.tech/blog/cloudflare-workers-inbound-tcp-grpc-2026)
- [Cloudflare changelog: TCP connect over VPC networks](https://developers.cloudflare.com/changelog/post/2026-06-16-tcp-connect-vpc-networks/)

Answering cost $0.11.

Grade

wrong

The judge's reason: It says only TCP is supported, but per the key UDP has been supported since 4.139.0; it also never states that the feature is local-only and cannot accept inbound sockets when deployed.

The judge's log

Session log

What the agent wrote, the tools it called, and what they returned, from docs/bench/2026-10-11-done3/runs/B-project/wrangler-4-125-0-19-b.jsonl. Thinking and the session's settings are left out. The raw log

  1. Tool call: ToolSearch

    {
      "query": "select:WebSearch",
      "max_results": 1
    }
  2. Tool output

    {"type":"tool_reference","tool_name":"WebSearch"}
  3. Tool call: WebSearch

    {
      "query": "Cloudflare Workers \"connect\" handler inbound TCP wrangler configuration",
      "mode": "standard"
    }
  4. Tool output

    Web search results for query: "Cloudflare Workers "connect" handler inbound TCP wrangler configuration"
    
    Links: [{"title":"github cloudflare/workers-sdk wrangler@4.125.0","url":"https://newreleases.io/project/github/cloudflare/workers-sdk/release/wrangler@4.125.0"},{"title":"github cloudflare/workers-sdk @cloudflare/workers-utils@0.34.0","url":"https://newreleases.io/project/github/cloudflare/workers-sdk/release/@cloudflare%2Fworkers-utils@0.34.0"},{"title":"cloudflare workers inbound tcp grpc 2026","url":"https://www.developersdigest.tech/blog/cloudflare-workers-inbound-tcp-grpc-2026"},{"title":"developers.cloudflare.com","url":"https://developers.cloudflare.com/workers/runtime-apis/nodejs/net/index.md"},{"title":"workers tcp socket api connect databases","url":"https://blog.cloudflare.com/ko-kr/workers-tcp-socket-api-connect-databases"},{"title":"2026 06 16 tcp connect vpc networks","url":"https://developers.cloudflare.com/changelog/post/2026-06-16-tcp-connect-vpc-networks/"},{"title":"Suscríbete para recibir notificaciones de nuevas publicaciones:","url":"https://blog.cloudflare.com/es-es/workers-tcp-socket-api-connect-databases"},{"title":"Subscribe to receive notifications of new posts:","url":"https://blog.cloudflare.com/workers-tcp-socket-api-connect-databases"},{"title":"4f1c5cd2.previews.developers.cloudflare.com","url":"https://4f1c5cd2.previews.developers.cloudflare.com/workers/runtime-apis/nodejs/net/index.md"},{"title":"codex-container-api-docs.previews.developers.cloudflare.com","url":"https://codex-container-api-docs.previews.developers.cloudflare.com/workers/runtime-apis/nodejs/net/index.md"}]
    
    The search turned up one clear answer for the wrangler side, plus some context that could be confused with it.
    
    **Wrangler config for the `connect` trigger:** The wrangler 4.125.0 release notes describe a `connect` trigger for raw sockets. It is configured with an entry like `"connect": [{ "protocol": "tcp", "port": 5432 }]`, and it applies during `wrangler dev`. The Worker receives each socket in its `connect(socket, env, ctx)` handler. Each entry opens a listening socket on 127.0.0.1 by default, or on an address you specify, and forwards connections directly to the Worker, skipping the local HTTP entry point. Two conditions: it requires the experimental compatibility flag, and only `"tcp"` is currently supported. The same release notes say `@cloudflare/config` offers a `triggers.connect(...)` helper that compiles down to that `connect` field. (Source: newreleases.io mirror of the workers-sdk release notes.)
    
    **Broader context:** A third-party write-up says inbound TCP support for Workers was announced on August 3 as part of Agents Week, and that it was in private beta at the time. It describes the `connect(socket)` handler as a new runtime handler that accepts an inbound TCP socket. (Source: developersdigest.tech blog; secondary, so verify against Cloudflare's own announcement.)
    
    **Don't confuse with:** Cloudflare's changelog covers `connect()` over VPC Network bindings, which is for *outbound* TCP to private destinations (e.g., Redis). That is a different feature from the inbound `connect` trigger. (Source: Cloudflare changelog, June 16, 2026.)
    
    **Gaps:** The results don't include Cloudflare's official docs for the inbound `connect` trigger, nor do they confirm how the trigger is configured for production deployments as opposed to `wrangler dev`. The official Wrangler configuration docs and the release notes would be the next places to check.
    
    
    REMINDER: You MUST include the sources above in your response to the user using markdown hyperlinks.
  5. Agent

    The `connect` handler is a newer Worker entry point that receives **inbound raw TCP connections**. You export `connect(socket, env, ctx)` alongside or instead of `fetch`, and the Worker reads and writes the socket directly. A third-party write-up says it was announced in private beta. Don't confuse it with `connect()` from `cloudflare:sockets`, which opens *outbound* TCP connections.
    
    According to the wrangler 4.125.0 release notes, you configure it with a `connect` trigger in your wrangler config, for example `"connect": [{ "protocol": "tcp", "port": 5432 }]`. Only `"tcp"` is supported for now, and you also need an experimental compatibility flag. In `wrangler dev`, each entry opens a listening socket (on 127.0.0.1 by default) and sends connections straight to your handler, skipping the HTTP entry point. I couldn't find official Cloudflare docs that give the exact flag name or explain how the trigger works in production deployments, so check the Wrangler configuration docs before relying on it.
    
    Sources:
    - [wrangler@4.125.0 release notes](https://newreleases.io/project/github/cloudflare/workers-sdk/release/wrangler@4.125.0)
    - [Cloudflare Workers inbound TCP/gRPC (developersdigest)](https://www.developersdigest.tech/blog/cloudflare-workers-inbound-tcp-grpc-2026)
    - [Cloudflare changelog: TCP connect over VPC networks](https://developers.cloudflare.com/changelog/post/2026-06-16-tcp-connect-vpc-networks/)