Public: anyone can read this; the crew can change it.
A public page waits past 1 s in the tunnel #14338
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/14261-a-public-page-waits-past-1-s-in-the-tunn → main 1 commit fork
4 files
changed +25
−1
infra/forge-box/cloudflared-forge.yml +6
| @@ -3,6 +3,12 @@ | ||
| 3 | 3 | # secret kept in /etc/forge, never in the repository. |
| 4 | 4 | tunnel: REPLACE-WITH-TUNNEL-ID |
| 5 | 5 | credentials-file: /etc/forge/cloudflared.json |
| 6 | originRequest: | |
| 7 | connectTimeout: 5s | |
| 8 | tcpKeepAlive: 15s | |
| 9 | noHappyEyeballs: true | |
| 10 | keepAliveConnections: 256 | |
| 11 | keepAliveTimeout: 5m | |
| 6 | 12 | ingress: |
| 7 | 13 | - hostname: "forge.open-platform.sh" |
| 8 | 14 | service: http://127.0.0.1:3000 |
src/maintain/wait_limits.ts +1 −1
| @@ -40,7 +40,7 @@ export const LIMITS: Readonly<Record<Exclude<Layer, "none">, Limit>> = { | ||
| 40 | 40 | }, |
| 41 | 41 | tunnel: { |
| 42 | 42 | kind: "none", |
| 43 | why: "the rendered cloudflared config (src/system/tunnel_config.ts, /etc/forge/cloudflared.yml) sets no originRequest timeouts, so cloudflared's own defaults apply; it only routes every hostname to the loopback origin", | |
| 43 | why: "the rendered cloudflared config (src/system/tunnel_config.ts, /etc/forge/cloudflared.yml) sets only the origin connection pool (ORIGIN_REQUEST: dial timeout, keep-alive reuse), which bounds a dial and not a response, and routes every hostname to the loopback origin", | |
| 44 | 44 | check: "`journalctl -u cloudflared` on the host for reconnects and origin errors, and whether the host's loopback answer (the accept layer) was fast at the same time", |
| 45 | 45 | }, |
| 46 | 46 | accept: { |
src/system/tunnel_config.ts +16
| @@ -7,6 +7,21 @@ | ||
| 7 | 7 | import type { Database } from "bun:sqlite"; |
| 8 | 8 | |
| 9 | 9 | export const FORGE_ORIGIN = "http://127.0.0.1:3000"; |
| 10 | /** | |
| 11 | * cloudflared's origin connection pool, for every rule. The origin is one loopback process, so | |
| 12 | * reuse costs nothing: keep many warm connections for long enough that a page never pays a fresh | |
| 13 | * dial, skip the dual-stack race (the origin is IPv4 literal), and fail a dial fast instead of | |
| 14 | * hanging. | |
| 15 | */ | |
| 16 | export const ORIGIN_REQUEST = [ | |
| 17 | "originRequest:", | |
| 18 | " connectTimeout: 5s", | |
| 19 | " tcpKeepAlive: 15s", | |
| 20 | " noHappyEyeballs: true", | |
| 21 | " keepAliveConnections: 256", | |
| 22 | " keepAliveTimeout: 5m", | |
| 23 | ] as const; | |
| 24 | ||
| 10 | 25 | export const FORGE_HOSTNAMES = [ |
| 11 | 26 | "forge.open-platform.sh", |
| 12 | 27 | "*--forge.open-platform.sh", |
| @@ -33,6 +48,7 @@ export function renderTunnelConfig(appHosts: readonly string[]): string { | ||
| 33 | 48 | "# secret kept in /etc/forge, never in the repository.", |
| 34 | 49 | "tunnel: REPLACE-WITH-TUNNEL-ID", |
| 35 | 50 | "credentials-file: /etc/forge/cloudflared.json", |
| 51 | ...ORIGIN_REQUEST, | |
| 36 | 52 | "ingress:", |
| 37 | 53 | ...FORGE_HOSTNAMES.map(rule), |
| 38 | 54 | " # one rule per verified app domain (app_domain)", |
test/forge-box-unit.test.ts +2
| @@ -178,6 +178,8 @@ test("the tunnel config has a rule for every verified app domain and none for an | ||
| 178 | 178 | for (const h of [...FORGE_HOSTNAMES, ...appDomainHosts(db)]) expect(text).toContain(`- hostname: "${h}"\n service: http://127.0.0.1:3000`); |
| 179 | 179 | expect(text).not.toContain("pending.example.org"); |
| 180 | 180 | expect(text.trimEnd().endsWith("- service: http_status:404")).toBe(true); |
| 181 | expect(text).toContain("originRequest:\n connectTimeout: 5s"); | |
| 182 | expect(text.indexOf("originRequest:")).toBeLessThan(text.indexOf("ingress:")); | |
| 181 | 183 | expect(() => renderTunnelConfig(["bad host\nservice: x"])).toThrow(); |
| 182 | 184 | }); |
| 183 | 185 |
new above
offline