Skip to content

fix(v1.7): give the session store its own file instead of sharing dd.json - #1063

Merged
scttbnsn merged 3 commits into
dev/v1.7from
fix/v1.7-session-store-own-file
Sep 6, 2026
Merged

scttbnsn merged 3 commits into
dev/v1.7from
fix/v1.7-session-store-own-file

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

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 in dd-sessions.json next to the main store via getSessionStorePath(). A legacy Sessions collection 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 in app/api/auth.ts applied cleanly.

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)
@vercel

vercel Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
drydock-website Ready Ready Preview Sep 6, 2026 2:39pm UTC
drydockdemo-website Ready Ready Preview Sep 6, 2026 2:39pm UTC

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 15e68f27-b10e-4f93-a060-5982303da91a

📥 Commits

Reviewing files that changed from the base of the PR and between 5b92b5f and e684955.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
📒 Files selected for processing (5)
  • app/api/auth.test.ts
  • app/api/auth.ts
  • app/store/index.ts
  • app/store/session-store-file.test.ts
  • content/docs/current/configuration/storage/index.mdx

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@biggest-littlest biggest-littlest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ALARGECOMPANY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@scttbnsn
scttbnsn merged commit 5e176ec into dev/v1.7 Sep 6, 2026
32 of 33 checks passed
@scttbnsn
scttbnsn deleted the fix/v1.7-session-store-own-file branch September 6, 2026 15:04

This branch was successfully deployed

2 active deployments
Preview – drydockdemo-website — e6849556 Deployed Sep 6, 2026 by vercel[bot]
Preview – drydock-website — e6849556 Deployed Sep 6, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants