You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: auth activation that fails after joining the host lease leaves the auth_servers row and a heartbeat timer running #979
Severity: low. Found in an adversarial review of #949 (#941).
Runtime revision and environment
origin/main ba9f3204, Node 26.10, macOS.
What happens
In packages/auth/src/auth.ts activation, lease = await joinHostLease(...) runs beforebetterAuth(options) and seedUsers(...). The catch only runs database?.close(), never lease?.close(). When a later step throws:
the auth_servers row stays until the TTL, which blocks another host from joining meanwhile;
the lease's heartbeat setInterval keeps firing against the closed connection indefinitely. Its errors are swallowed and the timer is unref'd, so it is a leak in long-lived processes such as MCP and restartable test runs, not a hang.
Store and audit do not have this problem: the store's opener closes on failure, and nothing follows the lease join there.
Minimal reproduction
Activate the auth extension hermetically with a seed that makes seedUsers throw, e.g. two users with the same email:
activation failed as expected: UNIQUE constraint failed: user.email
auth_servers rows after failed activation: [{ host: '<this host>', pid: <pid> }]
heartbeat callbacks fired after the failed activation: 2 (within ~11 s)
(Observed.)
Suggested fix
Call lease?.close() in that catch (before database?.close()), or join the lease as the last step of activation. Add a test.
Activity
fix: host lease survives clock skew and fails closed; sign-out confir…