trails/apps/planner/app
Ullrich Schäfer 0553cf4a5e
Fix planner_active_sessions gauge drifting negative
The gauge was maintained by conditional inc on "this sessionId isn't
in the in-memory `docs` Map yet" and dec on "last client for the
sessionId left." Because `docs` caches entries indefinitely — even
after every client disconnects — a reconnect found the doc still
cached, skipped the inc, then decremented again on the next
disconnect. Every reconnect-after-last-disconnect leaked one
decrement. After a day of normal reload / wifi-blip / tab-hibernate
patterns the gauge hit -182.

Replace the transitions with a `set()` derived from the live `conns`
map: count distinct session ids with at least one open WebSocket.
Self-correcting, no drift possible.

Extract `countActiveSessions()` as a pure helper + unit tests
including a regression case that simulates repeated reconnect/
disconnect cycles on one session and asserts the count never goes
negative.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 22:37:58 +02:00
..
components Session-bind /api/route and /api/overpass 2026-04-21 22:18:45 +02:00
jobs Add pg-boss background job queue with session expiry 2026-04-13 21:17:24 +02:00
lib Fix planner_active_sessions gauge drifting negative 2026-04-22 22:37:58 +02:00
routes Session-bind /api/route and /api/overpass 2026-04-21 22:18:45 +02:00
entry.client.tsx Add legal pages, ToS acceptance, and alpha banner 2026-04-18 00:08:48 +02:00
entry.server.tsx Consolidate Sentry config into shared package; fix inconsistencies 2026-04-18 00:30:09 +02:00
root.tsx Disable page zoom on iOS to prevent accidental pinch-to-zoom 2026-04-12 19:35:56 +02:00
routes.ts Route Overpass through server-side proxy with cache + coalescing 2026-04-18 02:04:50 +02:00