relay edge: tag auth-expiry closes and control opens with keepalive use and host silence (#40882)

Desktop closes for expired relay authorization rose after the keepalive release (3/day to ~35/day
on the edge cohort). The close metric now carries whether the control took the keepalive offer and
how long the host had been silent, and control_active carries keepalive use, so the cause can be
told apart (stalled desktop timers vs a control whose refresh stopped while it stayed live).
This commit is contained in:
Neil
2026-11-10 14:08:25 -08:00
committed by GitHub
parent 6dfb4dc60d
commit 557d588e69
3 changed files with 5 additions and 2 deletions
@@ -191,7 +191,7 @@ export abstract class HostRelayHandshake extends HostRelayBase {
})
// After the ack, which strict shipped parsers must see unchanged; only hosts that asked get it.
if (a.clientKeepalive) { this.send(ws, { type: 'keepalive-offer', v: 1, intervalMs: this.config.pingIntervalMs }) }
metric(this.env, 'control_active', 1, rebind ? 'rebind' : 'new', [], '', a.place)
metric(this.env, 'control_active', 1, rebind ? 'rebind' : 'new', [], a.clientKeepalive ? 'keepalive' : 'legacy', a.place)
await this.reschedule()
}
}
+2 -1
View File
@@ -187,7 +187,8 @@ export class HostRelay extends HostRelayPhones {
// Same order as the cells' heartbeat: expired auth past its grace, then the 6 h lease.
if (now > a.claims.exp + CONTROL_CONTINUITY_LIMITS.expiredAuthExistingSpliceGraceMs) {
const sinceRefreshS = a.lastRefreshAt === undefined ? -1 : Math.round((now - a.lastRefreshAt) / 1000)
metric(this.env, 'auth_expired_close', sinceRefreshS, a.lastRefreshAt === undefined ? 'never' : 'refreshed', [], '', a.place)
const seenAgoS = Math.round((now - seen) / 1000)
metric(this.env, 'auth_expired_close', sinceRefreshS, a.lastRefreshAt === undefined ? 'never' : 'refreshed', [seenAgoS], this.keepalive(a) ? 'keepalive' : 'legacy', a.place)
this.close(ws, RELAY_CLOSE_CODE.BAD_OUTER_CREDENTIAL, 'relay authorization expired')
await this.onSocketGone(ws, RELAY_CLOSE_CODE.BAD_OUTER_CREDENTIAL, '')
continue
+2
View File
@@ -2,6 +2,7 @@
import type { Env } from './env'
export type MetricEvent =
// label 'new' | 'rebind'; reason 'keepalive' | 'legacy' (took the keepalive offer or not).
| 'control_active'
| 'control_close'
| 'phone_open'
@@ -26,6 +27,7 @@ export type MetricEvent =
| 'control_upgrade'
// Control closed 4401 for expired authorization: value = seconds since its last extending
// refresh, label 'refreshed'; -1 and label 'never' when this socket never extended its token.
// double2 = seconds since the host's last inbound frame or keepalive; reason 'keepalive' | 'legacy'.
| 'auth_expired_close'
// Pre-auth socket refused by the per-source limiter: label 'phone' | 'data' | 'health'. Unpushed-host phones: 'not_on_edge'.
| 'preauth_limited'