#10725: fix: re-read session store inside lock in updateSessionStoreEntry
stale
Cluster:
Session Lock Improvements
## Summary
- `updateSessionStoreEntry` reads the session store inside a lock but uses the cached version (`loadSessionStore(storePath)` without `skipCache`)
- This means concurrent writes between the cache read and the lock acquisition can be silently overwritten
- The sibling function `updateSessionStore` (line 270) already handles this correctly with `{ skipCache: true }` and an explicit comment: _"Always re-read inside the lock to avoid clobbering concurrent writers"_
- This fix applies the same pattern for consistency and correctness
## Test plan
- [x] All session store tests pass (7 tests)
- [x] Change matches the established pattern in `updateSessionStore`
Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Fixes a race in `updateSessionStoreEntry` by re-reading the on-disk session store *inside* the session-store lock using `loadSessionStore(..., { skipCache: true })`.
- Aligns behavior with `updateSessionStore`, which already forces a fresh read under the lock to avoid overwriting concurrent writers.
- Adds an explanatory comment documenting why cache bypass is required in the locked section.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change is a small, localized correctness fix that matches an existing locking pattern in the same module and does not alter public APIs; it reduces the chance of lost updates under concurrency.
- src/config/sessions/store.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#10726: fix: re-read session store inside lock in updateLastRoute
by Yida-Dev · 2026-02-06
91.6%
#16987: fix(config): add skipCache to updateSessionStoreEntry and updateLas...
by AI-Reviewer-QS · 2026-02-15
90.6%
#15882: fix: move session entry computation inside store lock to prevent ra...
by cloorus · 2026-02-14
82.3%
#16609: fix: resolve session store race condition and contextTokens updates
by battman21 · 2026-02-14
80.6%
#4664: fix: per-session metadata files to eliminate lock contention
by tsukhani · 2026-01-30
79.0%
#15628: fix: resolve session write lock race condition
by 1kuna · 2026-02-13
77.0%
#16542: fix(sessions): use atomic temp+rename write on Windows
by aldoeliacim · 2026-02-14
75.5%
#20770: fix: prevent stale session-entry overwrite during reset-model persi...
by coygeek · 2026-02-19
74.5%
#20188: fix: Update sessionFile path when rolling to new session in cron jobs
by jriff · 2026-02-18
74.4%
#6653: fix: persist archived session entry on /new or /reset
by leicao-me · 2026-02-01
74.4%