Repository navigation
fix(v1.7): give the session store its own file instead of sharing dd.json - #1063
Conversation
DR-121: express-session's connect-loki store opened its own LokiJS
instance directly on ${configuration.path}/${configuration.file}, the
exact file the main store already used. LokiJS's saveDatabase() always
serializes the whole in-memory database, so whichever instance saved
last erased the other's writes: a session autosave (every 5 seconds,
armed by any authenticated request touching its session via
express-session's touch) reverted every container and setting written
since boot, while the main store's own autosave deleted the Sessions
collection out from under active logins.
store.getSessionStorePath() now derives a sibling file from the main
store's own configured path and file name (dd.json -> dd-sessions.json
by default), so a custom DD_STORE_FILE still lands on a distinct
sibling instead of colliding with anything else on the volume.
auth.ts's LokiStore now points at that path instead of building the
main store's own file path by hand. The main store also drops and logs
a stale Sessions collection left inside dd.json by an older build
instead of continuing to re-save it forever.
Replaces the shared-file-clobber reproduction test with
session-store-file.test.ts, asserting the two stores use different
files and that saving one never erases what the other wrote, including
the touch-driven case, a restart reload, and the legacy-collection
cleanup.
(cherry picked from commit 61b6857)
The storage page said mounting /store persists "the state" without naming what state, and now that sessions live in dd-sessions.json rather than inside dd.json itself, that sentence needs to say so explicitly so an operator mounting /store knows both files ride along. CHANGELOG bullet describes the user-visible effect of DR-121: containers or settings written after startup could vanish from dd.json after a crash or hard stop, and every restart logged users out, because the session store rewrote the same file. Notes that backups stay scoped to the main store file and sessions are not included. (cherry picked from commit 6c6d4bc)
dropLegacySessionsCollection() only removed the collection from the in-memory Loki database. loadDb() resolved without a save(), and autosave only fires on a later dirty write, so a store that never writes again kept the stale Sessions collection in dd.json across a restart. createCollections() now reports whether it dropped the collection, and loadDb() flushes once when it did. (cherry picked from commit 9215f27)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedNext included review available in 51 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
biggest-littlest
left a comment
There was a problem hiding this comment.
1.7 port of DR-121, three commits cherry-picked with -x, session-principal hunk dropped as the file does not exist on 1.7. Gate green, CI green.
ALARGECOMPANY
left a comment
There was a problem hiding this comment.
1.7 port of DR-121, three commits cherry-picked with -x, session-principal hunk dropped as the file does not exist on 1.7. Gate green, CI green.
1.7 port of DR-121 (#1055 on dev/v1.8).
The connect-loki session store and the main store both wrote
/store/dd.json, and whichever saved last erased the other's data. express-session touches the session on every authenticated read, so the session store rewrote the file within seconds while the main store autosaved every five minutes. Sessions now live indd-sessions.jsonnext to the main store viagetSessionStorePath(). A legacySessionscollection left in dd.json is dropped on init and the drop is persisted once.Three commits cherry-picked with -x. The only adaptation is that 1.7 has no
app/api/session-principal.ts, so the comment-only hunk there was dropped; the wiring inapp/api/auth.tsapplied cleanly.