LibreChat/packages/api
Danny Avila 446b73bb6b
🧯 fix: Harden Principals Cache Invalidation and Lock-Wait Paths (#14120)
* 🧯 fix: Harden Principals Cache Invalidation and Lock-Wait Paths

Follow-up hardening for the group-membership principals cache:

- Coalesce deferred transactional invalidations into one session `ended`
  listener so many membership writes in a transaction cannot trip the
  emitter's max-listeners warning
- Re-attempt the build lock inside the lock-wait poll so readers take over
  when the holder skips its write (invalidated away, failed, or crashed)
  instead of stalling for the full wait budget
- Read cache builds from the primary so secondaryPreferred deployments
  cannot pin a lagging secondary's pre-mutation memberships for the TTL
- Decouple the delayed stale-rewrite eviction pass from build locking via a
  crossProcess store marker, so USER_PRINCIPALS_LOCK_TTL_MS=0 disables
  locking only
- Treat aggregation-pipeline bulk updates touching memberIds as
  indeterminate (namespace clear) instead of silently skipping invalidation

* ⏲️ fix: Floor the Stale-Eviction Delay for Lockless Cache Builds

The second invalidation pass ran at only 500ms when build locking is
disabled (USER_PRINCIPALS_LOCK_TTL_MS=0), so a cross-container build slower
than that could still re-cache revoked memberships until the TTL. The store
now supplies an explicit staleEvictionDelayMs (lock wait plus one build
round-trip, floored at 3s), keeping the default locked budget unchanged.
2026-07-05 11:31:06 -04:00
..
src 🧯 fix: Harden Principals Cache Invalidation and Lock-Wait Paths (#14120) 2026-07-05 11:31:06 -04:00
types 🔬 ci: Add TypeScript Type Checks to Backend Workflow and Fix All Type Errors (#12451) 2026-03-28 21:06:39 -04:00
.gitignore
babel.config.cjs
jest.config.mjs 📦 chore: npm audit fix (#13828) 2026-06-17 21:54:04 -04:00
jest.setup.cjs 🌱 fix: Inject Code-Tool Files Into Graph Sessions on First Call (+ read_file Sandbox Fallback) (#12831) 2026-04-27 08:56:39 +09:00
package.json perf: Persist HITL checkpoints only on pause (lazy checkpointer) (#14024) 2026-07-05 08:30:06 -04:00
tsconfig-paths-bootstrap.mjs
tsconfig.build.json
tsconfig.json 📦 chore: npm audit fixes and Mongoose 8.23 TypeScript follow-ups (#12996) 2026-05-07 09:47:40 -04:00
tsconfig.spec.json 📦 chore: Update TypeScript Config for TS v7 (#12794) 2026-04-23 12:51:03 -04:00
tsdown.config.mjs 🪟 fix: Cross-Platform Absolute-Path Check in tsdown neverBundle Predicates (#13700) 2026-06-13 11:04:46 -04:00