Repository navigation
[v7.x] fix(session cache): fix bug in tls session caching (#5882) - #6017
Merged
mcollina merged 1 commit intoOct 15, 2026
Merged
Conversation
Spotted this one by accident. In the tls session cache, nodejs#5102 added logic to remove dead entries and make room, but the check used an early return that short circuited the cache operation. Signed-off-by: James M Snell <jasnell@gmail.com> (cherry picked from commit d983b4f) Signed-off-by: Mrityunjay Pandey <mrityunjayp1409@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v7.x #6017 +/- ##
==========================================
+ Coverage 93.11% 93.12% +0.01%
==========================================
Files 112 112
Lines 37366 37372 +6
==========================================
+ Hits 34793 34804 +11
+ Misses 2573 2568 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This relates to...
Backport of #5882 to v7.x.
Rationale
WeakSessionCache.set()on v7.x has the bug fixed by #5882. When the cache is full and it finds an entry whose session was already collected, it deletes that entry and thenreturns, so the new session is never stored. With a full cache, a new TLS session is silently dropped whenever there is a dead entry to clean up.v6.x is not affected: its
WeakSessionCachehas no eviction logic, which came in with #5102.Changes
test/tls-session-cache.js. Before the fix, that test fails on v7.x because sessionCis not cached:expected { name: 'C' }, actualnull.Features
N/A
Bug Fixes
Breaking Changes and Deprecations
N/A
Status
Tested locally on Linux with Node 24:
npm run test:unit(1322 tests, 1319 pass, 3 skipped, 0 fail) andnpm run lint.