session_recheck.ts view source
"/api/account/status" import {ACCOUNT_STATUS_PATH} from '@fuzdev/zzz/session_recheck.js'; The fuz_app account status route — 200 with a live session, 401 without.
Re-checking the session when the backend signals it may be gone.
A revoked WebSocket (WS_CLOSE_SESSION_REVOKED), an RPC unauthenticated
error, or a reconnect that keeps failing all hint the session ended —
revoked, expired, or logged out elsewhere. Each hint triggers a probe of the
account status endpoint, and only a definitive 401 counts: a network error
or 5xx means the backend is unreachable, not that the session is invalid,
so a daemon restart never logs the user out.
A valid session after a revoked socket is a real case, not noise: some
revocations close every socket of the account while ending only another
session (another tab's logout, an API-token revoke-all), so the caller
gets on_valid to rebuild its socket.
5 declarations
session_recheck.ts view source
"/api/account/status" import {ACCOUNT_STATUS_PATH} from '@fuzdev/zzz/session_recheck.js'; The fuz_app account status route — 200 with a live session, 401 without.
session_recheck.ts view source
(options: SessionRecheckOptions): () => Promise<void> import {create_session_recheck} from '@fuzdev/zzz/session_recheck.js'; Create a coalescing session recheck. Calls made while a recheck is in
flight share it, so a burst of unauthenticated errors costs one probe.
options() => Promise<void> a function that rechecks the session and resolves when done (never rejects)
session_recheck.ts view source
(fetch_status?: () => Promise<Response>): Promise<SessionProbe> import {probe_session} from '@fuzdev/zzz/session_recheck.js'; Probe the account status endpoint.
fetch_statusfetches the status route (injectable for tests)
() => Promise<Response>() => ui_fetch(ACCOUNT_STATUS_PATH)Promise<SessionProbe>
what the probe learned about the session
session_recheck.ts view source
SessionProbe type "valid" | "invalid" | "unknown"
import type {SessionProbe} from '@fuzdev/zzz/session_recheck.js'; What the status probe learned: valid (200), invalid (401), or unknown
(network failure or any other status — the session may well be fine).
session_recheck.ts view source
SessionRecheckOptions import type {SessionRecheckOptions} from '@fuzdev/zzz/session_recheck.js'; probe?Probes the session. Defaults to probe_session.
type (): Promise<SessionProbe>
Promise<SessionProbe>on_invalidCalled once the probe finds the session invalid — typically AuthState.check_session.
type (): void | Promise<void>
void | Promise<void>on_valid?Called once the probe finds the session still valid — e.g. to reconnect
a socket the server closed as revoked (see Socket.reconnect_revoked).
type (): void | Promise<void>
void | Promise<void>