-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: remove timeout for initial checkpoint service initialization in large repos #7844
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,25 @@ export async function getCheckpointService( | |
| } | ||
|
|
||
| if (task.checkpointServiceInitializing) { | ||
| await pWaitFor( | ||
| () => { | ||
| // For initial call during task startup, don't use timeout to allow large repos to initialize | ||
| const waitOptions = isInitialCall ? { interval } : { interval, timeout } | ||
|
|
||
| try { | ||
| await pWaitFor(() => { | ||
| console.log("[Task#getCheckpointService] waiting for service to initialize") | ||
| return !!task.checkpointService && !!task?.checkpointService?.isInitialized | ||
| }, | ||
| { interval, timeout }, | ||
| ) | ||
| }, waitOptions) | ||
| } catch (err) { | ||
| // Only disable checkpoints if this is not the initial call and we hit a timeout | ||
| if (!isInitialCall) { | ||
|
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. The error handling here seems incomplete. For initial calls that fail (not just timeout), we're not doing any logging or cleanup before re-throwing. Could we improve this to be more consistent with the non-initial call handling? |
||
| log("[Task#getCheckpointService] timeout waiting for service initialization, disabling checkpoints") | ||
| task.enableCheckpoints = false | ||
| return undefined | ||
| } | ||
| // For initial call, continue waiting or handle the error differently | ||
|
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. This comment says "continue waiting or handle the error differently" but we're actually just throwing the error. Should we update the comment to reflect what's actually happening, or implement the "continue waiting" logic? |
||
| throw err | ||
|
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 intentional? When |
||
| } | ||
|
|
||
| if (!task?.checkpointService) { | ||
| task.enableCheckpoints = false | ||
| return undefined | ||
|
|
||
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.
Could we add a test case for when
isInitialCall=trueand the initialization actually times out or fails? This would help ensure the error handling works as expected for the initial call scenario.