The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 19:15 UTC
fix(server): the PR cache sweep only removes real entry files (#16285)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Julius Marminge committed
Oct 5, 2026 at 21:38 UTC
bfe40e6d2574447b0651bdb41337db743ddbe12c
2 files changed
+8
-3
apps/server/src/pullRequest/PullRequestReadCache.test.ts
+5
-2
@@ -44,18 +44,21 @@ it.layer(NodeServices.layer)("PR filesystem cache", (it) => {
44
);
45
const unrelated = "unrelated.json";
46
yield* fs.writeFileString(`${directory}/${unrelated}`, "{}");
47
+ // Starts with the store id but is not an entry file.
48
+ const prefixed = "pr-v2-backup.json";
49
+ yield* fs.writeFileString(`${directory}/${prefixed}`, "{}");
50
const justExpired = Duration.sum(
51
PullRequestReadCache.ENTRY_FILE_MAX_AGE,
52
Duration.seconds(1),
53
);
51
- yield* ageFiles(directory, [stale!, revisions!, unrelated], justExpired);
54
+ yield* ageFiles(directory, [stale!, revisions!, unrelated, prefixed], justExpired);
55
yield* ageFiles(directory, [fresh!], PullRequestReadCache.ENTRY_FILE_MAX_AGE);
56
57
yield* PullRequestReadCache.pruneExpiredEntryFiles(directory);
58
59
assert.deepStrictEqual(
60
(yield* fs.readDirectory(directory)).toSorted(),
58
- [fresh!, revisions!, unrelated].toSorted(),
61
+ [fresh!, revisions!, unrelated, prefixed].toSorted(),
62
);
63
}),
64
);
apps/server/src/pullRequest/PullRequestReadCache.ts
+3
-1
@@ -27,6 +27,8 @@ const CONCURRENT_READS = 512;
27
// Persistence prefixes every entry key with the store id, so each entry file
28
// name starts with it. The scope `revisions` file does not.
29
const STORE_ID = "pr-v2";
30
+// An entry file is the store id followed by the SHA-256 hex digest of its key.
31
+const ENTRY_FILE_NAME = new RegExp(`^${STORE_ID}[0-9a-f]{64}$`);
32
/**
33
* Entries expire a minute after they are written, and a write sets the file's
34
* mtime. A file untouched for a day is long expired; the day only leaves slack
@@ -186,7 +188,7 @@ export const pruneExpiredEntryFiles = Effect.fn("PullRequestReadCache.pruneExpir
188
const path = yield* Path.Path;
189
const cutoff = (yield* Clock.currentTimeMillis) - Duration.toMillis(ENTRY_FILE_MAX_AGE);
190
const entries = (yield* fileSystem.readDirectory(directory)).filter((name) =>
189
- name.startsWith(STORE_ID),
191
+ ENTRY_FILE_NAME.test(name),
192
);
193
// One file at a time, and `partition` visits every file, so one locked file
194
// does not stop the sweep.