Skip to content

Commit e1c0e36

Browse files
fix(relay): age a down tunnel only from when it lost its connector
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 4a40b34 commit e1c0e36

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎infra/relay/scripts/tunnel-census.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ const TunnelPage = Schema.Struct({ result: Schema.Array(Tunnel) });
3737
const stageOf = (name: string | null | undefined) =>
3838
name ? name.slice(PREFIX.length).replace(/-[a-f0-9]{16}$/u, "") : "unknown";
3939

40+
// Like the reaper: a down tunnel is aged from when it lost its connector, and a
41+
// never-connected (inactive) one from when it was created.
4042
const ageBucket = (tunnel: Tunnel, now: number) => {
41-
const since = Date.parse(tunnel.conns_inactive_at ?? tunnel.created_at ?? "");
43+
const since = Date.parse(
44+
(tunnel.status === "down" ? tunnel.conns_inactive_at : tunnel.created_at) ?? "",
45+
);
4246
if (Number.isNaN(since)) return "unknown";
4347
const days = (now - since) / DAY_MS;
4448
if (days > 90) return ">90d";

0 commit comments

Comments
 (0)