Repository navigation
[PR] fix(gc): retain sessions when companion metadata is unreadable - #7298
Merged
ranxianglei merged 1 commit intoNov 21, 2026
Merged
ranxianglei merged 1 commit into
ranxianglei merged 1 commit into
Conversation
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.
Fixes #7297
What and why
A failed
stat()on a session's content-store companion is currently treated as absence. GC can therefore omit that companion from the token-size gate, delete its session, and then delete the now-orphaned originals when the transient metadata error clears. Existing-but-unsupported companion types also incorrectly pass as absent.Only
ENOENTnow permits the no-companion path. Other errors and non-file results retain the owner before any resident-session removal or unlink, so the orphan sweep still sees its reference. The sweep continues to process independent eligible sessions and logs why this session was kept.Validation
EIO,EACCES,ELOOP) while using real temporary session/companion files. All fail on the base: two sessions are removed instead of only the independent eligible one, and the original content is orphan-collected.bytesFreedincludes only the independent eligible session andcompanionsRemovedstays zero.tests/session-gc.test.ts: 30 passed, 0 failed, 0 skipped, including existing absent-companion, normal co-deletion, token-size, surviving-twin, encrypted-file, resident/pending-save and request-path cases.git diff --checkpass.Validated on Linux / Node.js 24.22.3 against
6453feeeb842bd1e471d875bf00287e5036a96c7(0.1.216) with both standard test-isolation preloads. The full repository regression verdict remains the remote CI on this PR's head.Scope
This restores the existing retain-unreadable-data policy. The opt-in, age and token thresholds are unchanged. There is no kernel, persisted-format, wire or model-facing-text change. The earlier #6143 fixes malformed parsed records, while this change handles metadata failure before a companion can be read.