Clean up leaked tmp_pack files after failed status refresh #2026
ClosedSAKETH11111(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/2026/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- apps/server/src/git/Layers/GitCore.ts line 940OutdatedResolvedby SAKETH11111(GitHub profile, opens in a new tab)@@ -928,7 +927,14 @@928- fetchCwd,929- ["--git-dir", gitCommonDir, "fetch", "--quiet", "--no-tags", remoteName],930- {931- allowNonZeroExit: true,932- timeoutMs: Duration.toMillis(STATUS_UPSTREAM_REFRESH_TIMEOUT),933- },934- ).pipe(Effect.asVoid);927+928+ const readTemporaryPackFiles = Effect.fn("readTemporaryPackFiles")(function* () {929+ const packDir = path.join(gitCommonDir, "objects", "pack");930+ const entries = yield* fileSystem931+ .readDirectory(packDir, { recursive: false })932+ .pipe(Effect.orElseSucceed(() => [] as Array<string>));933+ return new Set(934+ entries.filter((entry) => entry.startsWith(TEMPORARY_PACK_FILE_PREFIX)),935+ ) as ReadonlySet<string>;936+ });937+938+ const hasConcurrentFetchLock = Effect.fn("hasConcurrentFetchLock")(function* () {939+ return yield* fileSystem940+ .exists(path.join(gitCommonDir, "FETCH_HEAD.lock"))
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge closed this
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
Implement cleanup mechanism for leaked temporary pack files created during failed git fetch operations. Records existing
tmp_pack_*files before fetch, then removes newly-created ones on fetch failure, with concurrency protection viaFETCH_HEAD.lockdetection.Changes#
apps/server/src/git/Layers/GitCore.tsfetchRemoteForStatusto track pre-fetch temporary pack files and clean up new ones on fetch failure, respecting concurrent fetch locks and logging warnings.apps/server/src/git/Layers/GitCore.test.tsit.effecttests: one verifying cleanup removes newly-createdtmp_pack_newwhile preserving existing files, another verifying cleanup is skipped whenFETCH_HEAD.lockindicates concurrent fetch.Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem#
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
#1965: snapshots tmp_pack files before fetch, removes only newly created ones on failure, skips cleanup on concurrent fetch lock, and adds regression tests.✨ Finishing Touches
🧪 Generate unit tests (beta)
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