-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: improve checkpoint initialization for large repositories #7847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,11 @@ import { CheckpointServiceOptions, RepoPerTaskCheckpointService } from "../../se | |
|
|
||
| export async function getCheckpointService( | ||
| task: Task, | ||
| { interval = 250, timeout = 15_000 }: { interval?: number; timeout?: number } = {}, | ||
| { | ||
| interval = 250, | ||
| timeout = 15_000, | ||
| isInitialCall = false, | ||
| }: { interval?: number; timeout?: number; isInitialCall?: boolean } = {}, | ||
| ) { | ||
| if (!task.enableCheckpoints) { | ||
| return undefined | ||
|
|
@@ -67,13 +71,14 @@ export async function getCheckpointService( | |
| } | ||
|
|
||
| if (task.checkpointServiceInitializing) { | ||
| await pWaitFor( | ||
| () => { | ||
| console.log("[Task#getCheckpointService] waiting for service to initialize") | ||
| return !!task.checkpointService && !!task?.checkpointService?.isInitialized | ||
| }, | ||
| { interval, timeout }, | ||
| ) | ||
| // If this is the initial call from initiateTaskLoop, don't apply a timeout | ||
| // to allow large repositories to complete initialization | ||
| const waitOptions = isInitialCall ? { interval } : { interval, timeout } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this approach thread-safe? While the |
||
|
|
||
| await pWaitFor(() => { | ||
| console.log("[Task#getCheckpointService] waiting for service to initialize") | ||
| return !!task.checkpointService && !!task?.checkpointService?.isInitialized | ||
| }, waitOptions) | ||
| if (!task?.checkpointService) { | ||
| task.enableCheckpoints = false | ||
| return undefined | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1661,7 +1661,8 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike { | |
|
|
||
| private async initiateTaskLoop(userContent: Anthropic.Messages.ContentBlockParam[]): Promise<void> { | ||
| // Kicks off the checkpoints initialization process in the background. | ||
| getCheckpointService(this) | ||
| // Pass isInitialCall=true to avoid timeout for large repositories | ||
| getCheckpointService(this, { isInitialCall: true }) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we expand this comment to be more descriptive? Consider adding more context about why |
||
|
|
||
| let nextUserContent = userContent | ||
| let includeFileDetails = true | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,7 +145,9 @@ export abstract class ShadowCheckpointService extends EventEmitter { | |
|
|
||
| private async stageAll(git: SimpleGit) { | ||
| try { | ||
| await git.add(".") | ||
| // Use --ignore-errors to continue even if some files can't be added (e.g., permission issues) | ||
| // This prevents the operation from failing in large repositories with problematic files | ||
| await git.add([".", "--ignore-errors"]) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good addition of the |
||
| } catch (error) { | ||
| this.log( | ||
| `[${this.constructor.name}#stageAll] failed to add files to git: ${error instanceof Error ? error.message : String(error)}`, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 15-second timeout is still hardcoded for subsequent calls. Would it be beneficial to make this configurable through settings? Users with varying repository sizes might need different timeout values.