Claude Opus 5.5

wrangler-4-125-0-19-b

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

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

A `connect` handler is a Worker entry point, next to `fetch` and `scheduled`, that receives raw TCP socket connections instead of HTTP requests. You export it as `connect(socket, env, ctx)` on your default export, then read from and write to the socket directly. In wrangler (4.125.0 or later; you have 4.148.0 installed), you add a `connect` entry to your config with `protocol` set to `tcp` and a `port`. `wrangler dev` then listens on that port and sends incoming connections to your handler.

This comes from the project's `.ludion/lessons.md` notes, not from my own knowledge, since the feature is newer than my training data. The notes only mention `protocol` and `port` and don't show the exact config layout. Check the wrangler 4.125+ changelog or the config schema (`node_modules/wrangler/config-schema.json`) for the precise shape, such as whether it's a single object or an array. The notes also only describe this working during `wrangler dev`, so I can't confirm how it behaves once deployed.

Answering cost $0.08.

Grade

correct

The judge's reason: It correctly describes the `connect(socket, env, ctx)` handler and the wrangler `connect` entry with protocol/port for TCP since 4.125.0 in `wrangler dev`, and states nothing stale or false, though it omits UDP support and only hedges on the local-only limitation.

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-sync/wrangler-4-125-0-19-b.jsonl. Thinking and the session's settings are left out. The raw log

  1. Agent

    A `connect` handler is a Worker entry point, next to `fetch` and `scheduled`, that receives raw TCP socket connections instead of HTTP requests. You export it as `connect(socket, env, ctx)` on your default export, then read from and write to the socket directly. In wrangler (4.125.0 or later; you have 4.148.0 installed), you add a `connect` entry to your config with `protocol` set to `tcp` and a `port`. `wrangler dev` then listens on that port and sends incoming connections to your handler.
    
    This comes from the project's `.ludion/lessons.md` notes, not from my own knowledge, since the feature is newer than my training data. The notes only mention `protocol` and `port` and don't show the exact config layout. Check the wrangler 4.125+ changelog or the config schema (`node_modules/wrangler/config-schema.json`) for the precise shape, such as whether it's a single object or an array. The notes also only describe this working during `wrangler dev`, so I can't confirm how it behaves once deployed.