Skip to content

Commit 17f19a5

Browse files
committed
fix: improve checkpoint initialization for large repositories
- Add --ignore-errors flag to git add command to handle permission issues - Remove timeout for initial checkpoint service initialization - Keep timeout only for subsequent calls when service is already initializing This fixes issue #7843 where checkpoints would fail to initialize in large repositories due to the 15-second timeout being too short for git add operations.
1 parent 7cd6520 commit 17f19a5

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/core/checkpoints/index.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import { CheckpointServiceOptions, RepoPerTaskCheckpointService } from "../../se
1818

1919
export async function getCheckpointService(
2020
task: Task,
21-
{ interval = 250, timeout = 15_000 }: { interval?: number; timeout?: number } = {},
21+
{
22+
interval = 250,
23+
timeout = 15_000,
24+
isInitialCall = false,
25+
}: { interval?: number; timeout?: number; isInitialCall?: boolean } = {},
2226
) {
2327
if (!task.enableCheckpoints) {
2428
return undefined
@@ -67,13 +71,14 @@ export async function getCheckpointService(
6771
}
6872

6973
if (task.checkpointServiceInitializing) {
70-
await pWaitFor(
71-
() => {
72-
console.log("[Task#getCheckpointService] waiting for service to initialize")
73-
return !!task.checkpointService && !!task?.checkpointService?.isInitialized
74-
},
75-
{ interval, timeout },
76-
)
74+
// If this is the initial call from initiateTaskLoop, don't apply a timeout
75+
// to allow large repositories to complete initialization
76+
const waitOptions = isInitialCall ? { interval } : { interval, timeout }
77+
78+
await pWaitFor(() => {
79+
console.log("[Task#getCheckpointService] waiting for service to initialize")
80+
return !!task.checkpointService && !!task?.checkpointService?.isInitialized
81+
}, waitOptions)
7782
if (!task?.checkpointService) {
7883
task.enableCheckpoints = false
7984
return undefined

src/core/task/Task.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,8 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
16611661

16621662
private async initiateTaskLoop(userContent: Anthropic.Messages.ContentBlockParam[]): Promise<void> {
16631663
// Kicks off the checkpoints initialization process in the background.
1664-
getCheckpointService(this)
1664+
// Pass isInitialCall=true to avoid timeout for large repositories
1665+
getCheckpointService(this, { isInitialCall: true })
16651666

16661667
let nextUserContent = userContent
16671668
let includeFileDetails = true

src/services/checkpoints/ShadowCheckpointService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ export abstract class ShadowCheckpointService extends EventEmitter {
145145

146146
private async stageAll(git: SimpleGit) {
147147
try {
148-
await git.add(".")
148+
// Use --ignore-errors to continue even if some files can't be added (e.g., permission issues)
149+
// This prevents the operation from failing in large repositories with problematic files
150+
await git.add([".", "--ignore-errors"])
149151
} catch (error) {
150152
this.log(
151153
`[${this.constructor.name}#stageAll] failed to add files to git: ${error instanceof Error ? error.message : String(error)}`,

0 commit comments

Comments
 (0)