fix(server): T3 Connect switches to HTTP/2 when cloudflared keeps failing its first QUIC registration #48218
main fromrefs/pull/48218/head·merged by juliusmarminge View on GitHubWhen cloudflared's first QUIC tunnel registration kept timing out (for example while UDP is blocked or the edge is degraded), cloudflared exited before its own HTTP/2 fallback could run. T3 Connect then restarted it with protocol=auto forever, and the tunnel never came up. T3 now counts these startup registration timeouts. After three in a row with no successful registration, it switches the managed cloudflared to --protocol http2 and remembers that choice, the same way it already does for repeated QUIC stalls.
Fixes pingdotgg/t3code#48208
Reproduction on main#
Commit 7b7ca65f9a (origin/main), Linux VM, server CLI (t3 serve) linked to the T3 Connect test stage with the managed cloudflared 2026.10.4 and no TUNNEL_TRANSPORT_PROTOCOL set. Steps: t3 connect login --headless and t3 connect link with a fresh --base-dir; started t3 serve in its own systemd scope; dropped UDP 7844 only for that scope with iptables (TCP 7844 untouched).
Run 1 (OUTPUT drop after the first 3 packets of each QUIC flow): the first cloudflared (protocol auto) logged ERR Register tunnel error from server side error="rpc: connection closed", then ERR initial tunnel connection failed error="control stream error: rpc: connection closed", and exited with code 1 after 8 s. T3 counted no QUIC stall, logged no HTTP/2 switch, and restarted it with protocol: auto. This is the reporter's sequence. In my run the second process got fast sendmsg: operation not permitted errors, so cloudflared fell back to http2 on its own within 28 s, and T3 persisted that (#34167).
Run 2 (silent inbound drop, fallback state cleared): cloudflared logged timeout: no recent network activity and fell back to http2 on its own within 6 s.
So the T3 side of the report shows in a real run: an exit during initial registration counts toward nothing and the next start uses auto again. The endless loop also needs the edge to fail registration on every attempt, as it did during the reporter's Cloudflare outage, and I could not force that. Failing test on branch factory/repro-48208 (14acfeba62), in apps/server/src/cloud/ManagedEndpointRuntime.test.ts, "falls back to HTTP/2 when QUIC registration keeps timing out at startup": it feeds the reporter's two log lines followed by exit 1, ten times in a row, and on main the eleventh spawn still has no --protocol http2.
Evidence#
Evidence\n\nSteps on both commits: run the managed cloudflared supervisor with ten repeated startup registration failures (rpc: connection closed / context deadline exceeded), advance restart backoff, and inspect the next spawn.\n\n| Before — base 7b7ca65f | After — fix cb19792b |\n| --- | --- |\n| base runtime capture shows the next process still starts without --protocol http2 (the received args are --metrics 127.0.0.1:0 run). | head runtime capture passes after the supervisor starts HTTP/2 and persists it. |\n\nDriver/test source: issue-48208-repro.test.ts#
Not shown:
- The reporter's exact live Cloudflare outage and packet-filtered cloudflared process were unavailable in this VM; evidence uses T3 Code's managed-runtime harness with the reporter's captured cloudflared log sequence, so edge-level networking was not independently re-created.
Tests#
vp test run src/cloud/ManagedEndpointRuntime.test.ts -t "QUIC registration keeps timing out"without the fix: 1 failed (reproduces the bug)vp test run src/cloud/ManagedEndpointRuntime.test.tswith the fix: 32 passedvp run typecheck(apps/server): no errorsvp run check:changed: fmt, lint, knip, typecheck and tests all pass- CI on cb19792: all 8 required checks passed
Not in this change#
- The threshold of 3 startup failures is a new constant (
QUIC_STARTUP_FAILURES_BEFORE_HTTP2); its value was not tuned against real outages. - Not verified end to end against the T3 Connect test stage: forcing the edge to fail registration on every attempt could not be reproduced.
Who did the work#
- Written by Claude Opus 5.5, in Claude Code
- Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
- Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5
Run by the t3code factory in T3 Code.
- 1
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅ Codex Live turn messages 1 1 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅ Claude Live turn messages 1 1 0 (0.0%) 8 ✅ Other scenarios#
All 64 scenario measurements match
main.All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling Codex short turn resumeWebSocket decoded10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅ Codex short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn running, cold openHTTP decoded281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅ Codex long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Codex long turn running, history pageHTTP decoded92.5 KiB 92.5 KiB 0 B (0.0%) 107.4 KiB ✅ Codex long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Codex long turn finished, cold openHTTP decoded381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, socket cold openWebSocket decoded381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, work pageHTTP decoded78.3 KiB 78.3 KiB 0 B (0.0%) 200.2 KiB ✅ Codex long turn finished, work pagerows75 75 0 (0.0%) 150 ✅ Codex idle thread resumeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell snapshotHTTP decoded42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅ Codex fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Codex fleet shell subscribeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Codex fleet shell resume checkrows0 0 0 0 ✅ Codex stale shell reloadHTTP decoded42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅ Codex stale shell reloadrows27 27 0 (0.0%) 27 ✅ Codex stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Codex stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex stale todo list cold openHTTP decoded72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅ Codex stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Codex stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Codex stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Codex stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Codex stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Codex stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Claude short turn resumeWebSocket decoded10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅ Claude short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn running, cold openHTTP decoded283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅ Claude long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Claude long turn running, history pageHTTP decoded93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅ Claude long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Claude long turn finished, cold openHTTP decoded384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, socket cold openWebSocket decoded384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, work pageHTTP decoded79.2 KiB 79.2 KiB 0 B (0.0%) 200.2 KiB ✅ Claude long turn finished, work pagerows75 75 0 (0.0%) 150 ✅ Claude idle thread resumeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell snapshotHTTP decoded43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅ Claude fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Claude fleet shell subscribeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Claude fleet shell resume checkrows0 0 0 0 ✅ Claude stale shell reloadHTTP decoded43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅ Claude stale shell reloadrows27 27 0 (0.0%) 27 ✅ Claude stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Claude stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude stale todo list cold openHTTP decoded73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅ Claude stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Claude stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Claude stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Claude stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Claude stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Claude stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Baseline:
7eba80e· PR result:cb19792· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
juliusmarminge merged this9a08ffb
juliusmarminge closed this
Sign in to join this conversation.
Approvability#
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — T3 Connect now automatically selects HTTP/2 after three QUIC startup-registration failures, preserving the fallback across restarts while respecting explicit transport choices. This changes default transport-recovery behavior and requires human confirmation of that product choice.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).