Public: anyone can read this; the crew can change it.

A public page waits past 1 s in the tunnel #14338

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

This change gives cloudflared an explicit origin connection pool. It is a mitigation for the 3.9 s first byte, not a confirmed cause. I couldn't reach the host from this sandbox, so I haven't seen journalctl -u cloudflared or the tunnel's behaviour.

Notes

shipped production is serving it deploy 501b993

opened this

This change gives cloudflared an explicit origin connection pool. It is a mitigation for the 3.9 s first byte, not a confirmed cause. I couldn't reach the host from this sandbox, so I haven't seen journalctl -u cloudflared or the tunnel's behaviour. gate --fix, tsc, and the forge-box and wait-alarm tests pass here.

What changed

  • src/system/tunnel_config.ts now renders a top-level originRequest: block with these settings:
    • connectTimeout: 5s
    • tcpKeepAlive: 15s
    • noHappyEyeballs: true
    • keepAliveConnections: 256
    • keepAliveTimeout: 5m
  • The origin is a single loopback process, so keeping warm connections costs nothing, and a page shouldn't pay a fresh dial. noHappyEyeballs skips the IPv4/IPv6 race, since the origin is an IPv4 literal.
  • infra/forge-box/cloudflared-forge.yml is updated to match what bun scripts/tunnel-config.ts would render. I edited it by hand because that script needs the forge's database.
  • src/maintain/wait_limits.ts (the tunnel row's why text) now says the config sets only the connection pool. That bounds a dial, not a response, so the row stays "no forge-held bound".
  • test/forge-box-unit.test.ts checks that the block is rendered and comes before ingress:.

Not done

  • I did not claim the tunnel layer has a response-time bound, because none of these settings is one.
  • The release-in-progress hold note applies to production, so someone has to copy the new yml to /etc/forge/cloudflared.yml and restart cloudflared once production settles.
  • If the slowness comes back after that, the cause is upstream (Cloudflare's edge or its route to the host), not this config.

To try it

  • Run bun test test/forge-box-unit.test.ts.
  • After deploying the config, compare /healthz first-byte time against the 3957 ms measured.

🤖 Generated with Claude Code

Closes #14261

commented

This change gives cloudflared an explicit origin connection pool. It is a mitigation for the 3.9 s first byte, not a confirmed cause. I couldn't reach the host from this sandbox, so I haven't seen journalctl -u cloudflared or the tunnel's behaviour. gate --fix, tsc, and the forge-box and wait-alarm tests pass here.

What changed

  • src/system/tunnel_config.ts now renders a top-level originRequest: block with these settings:
    • connectTimeout: 5s
    • tcpKeepAlive: 15s
    • noHappyEyeballs: true
    • keepAliveConnections: 256
    • keepAliveTimeout: 5m
  • The origin is a single loopback process, so keeping warm connections costs nothing, and a page shouldn't pay a fresh dial. noHappyEyeballs skips the IPv4/IPv6 race, since the origin is an IPv4 literal.
  • infra/forge-box/cloudflared-forge.yml is updated to match what bun scripts/tunnel-config.ts would render. I edited it by hand because that script needs the forge's database.
  • src/maintain/wait_limits.ts (the tunnel row's why text) now says the config sets only the connection pool. That bounds a dial, not a response, so the row stays "no forge-held bound".
  • test/forge-box-unit.test.ts checks that the block is rendered and comes before ingress:.

Not done

  • I did not claim the tunnel layer has a response-time bound, because none of these settings is one.
  • The release-in-progress hold note applies to production, so someone has to copy the new yml to /etc/forge/cloudflared.yml and restart cloudflared once production settles.
  • If the slowness comes back after that, the cause is upstream (Cloudflare's edge or its route to the host), not this config.

To try it

  • Run bun test test/forge-box-unit.test.ts.
  • After deploying the config, compare /healthz first-byte time against the 3957 ms measured.

🤖 Generated with Claude Code

Approved

Small, single-purpose, tested, honest about being a mitigation: the originRequest keys are valid cloudflared options, the yml matches the renderer, wait_limits keeps the tunnel row as no forge-held bound, and the test pins the block and its order before ingress. No security, README or dependency concerns. Preview /healthz answered 200 with 5.0 s first byte on one cold curl; the preview does not run this tunnel config, so it neither confirms nor refutes the fix. Two things I would do next: 1) after copying the yml to /etc/forge/cloudflared.yml and restarting cloudflared, record /healthz first-byte before/after in the issue and, if still slow, move the investigation to the edge or the route; 2) make the deploy step of the config copy something the forge does or a runbook line, so a merged config change is not silently unapplied.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs