fix(server): queued messages no longer wait out every timed-out checkpoint in a shared folder #40411
MergedExSidius(GitHub profile, opens in a new tab)merged 6 commits into
main fromrefs/pull/40411/headmerged by juliusmarminge View on GitHubtanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- @@ -647,16 +645,5 @@647- checkpointRef,648- head: input.cleanHead,649- })650- ).pipe(651- Effect.as("ready" as const),652- Effect.catchTags({653- VcsUnsupportedOperationError: () => Effect.succeed("missing" as const),654- }),655- Effect.catch((cause) =>656- Effect.logWarning("orchestration V2 checkpoint capture failed", {657- scopeId: input.scope.id,658- checkpointRef,659- cause: String(cause),660- }).pipe(Effect.as("error" as const)),661- ),662- );645+ // Threads sharing a folder queue on its lock. One that waited out another's timeout646+ // would only time out again while its own queued messages wait behind it.647+ const timedOutWhileWaiting =648+ input.cleanHead === undefined &&649+ (yield* Cache.get(captureTimeouts, input.scope.cwd)) > timeoutsBeforeLock;
Pushed28576e0
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
juliusmarminge added labelstakeover:in-progress
- @@ -391,11 +400,20 @@400+ ) {401+ return yield* withWorkspaceLock(cwd, effect(lastCaptures.get(cwd)?.count ?? 0));402+ });391403 // Both callers hold the workspace lock; post-turn captures always probe for recovery.392404 const captureWorkspaceCheckpoint = Effect.fn("CheckpointService.captureWorkspaceCheckpoint")(393405 function* (input: CheckpointStore.CaptureCheckpointInput, baseline = false) {394406 const capture = checkpointStore.captureCheckpoint(input);395407 yield* (baseline ? capture.pipe(Effect.timeout(BASELINE_CAPTURE_BUDGET)) : capture).pipe(396- Effect.tap(() => Cache.invalidate(captureTimeouts, input.cwd)),408+ Effect.tap(() =>409+ Effect.andThen(410+ Cache.invalidate(captureTimeouts, input.cwd),411+ noteCapture(input.cwd, false),412+ ),413+ ),397414 Effect.tapError((error) =>398415 error._tag === "VcsProcessTimeoutError" || error._tag === "TimeoutError"399416 ? Effect.gen(function* () {400417 const previous = yield* Cache.get(captureTimeouts, input.cwd);401418 yield* Cache.set(captureTimeouts, input.cwd, previous + 1);419+ yield* noteCapture(input.cwd, true);
Pushedec110f6
- @@ -388,3 +388,15 @@388388 capacity: 128,389389 lookup: () => Effect.succeed(0),390390 });391+ // Unlike the streak, a success never rewinds the count, so a waiter can order outcomes. A392+ // baseline running out of its short budget is not a post-turn capture timing out.393+ const lastCaptures = new Map<string, { readonly count: number; readonly timedOut: boolean }>();394+ const noteCapture = (cwd: string, timedOut: boolean) =>395+ Effect.sync(() => {396+ lastCaptures.set(cwd, { count: (lastCaptures.get(cwd)?.count ?? 0) + 1, timedOut });397+ });398+ const withCaptureLock = Effect.fn("CheckpointService.withCaptureLock")(function* <A, E, R>(399+ cwd: string,400+ effect: (capturesBeforeLock: number) => Effect.Effect<A, E, R>,401+ ) {402+ return yield* withWorkspaceLock(cwd, effect(lastCaptures.get(cwd)?.count ?? 0));@@ -393,11 +406,19 @@393406 function* (input: CheckpointStore.CaptureCheckpointInput, baseline = false) {394407 const capture = checkpointStore.captureCheckpoint(input);395408 yield* (baseline ? capture.pipe(Effect.timeout(BASELINE_CAPTURE_BUDGET)) : capture).pipe(396- Effect.tap(() => Cache.invalidate(captureTimeouts, input.cwd)),409+ Effect.tap(() =>410+ Effect.andThen(411+ Cache.invalidate(captureTimeouts, input.cwd),412+ noteCapture(input.cwd, false),413+ ),414+ ),397415 Effect.tapError((error) =>398416 error._tag === "VcsProcessTimeoutError" || error._tag === "TimeoutError"399417 ? Effect.gen(function* () {400418 const previous = yield* Cache.get(captureTimeouts, input.cwd);401419 yield* Cache.set(captureTimeouts, input.cwd, previous + 1);420+ yield* noteCapture(input.cwd, !baseline);402421 })403- : Cache.invalidate(captureTimeouts, input.cwd),422+ : Effect.andThen(423+ Cache.invalidate(captureTimeouts, input.cwd),424+ noteCapture(input.cwd, false),
Sign in to join this conversation.




Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
Walkthrough
The capture service tracks capture counts and timeout outcomes by workspace. When a post-turn capture times out while another capture waits for the workspace lock, the waiting capture returns an error without starting another probe. Tests cover queued captures and subsequent attempts.
Changes: Workspace capture timeout handling
apps/server/src/orchestration-v2/CheckpointService.ts,apps/server/src/orchestration-v2/CheckpointCaptureService.ts,apps/server/src/orchestration-v2/CheckpointService.test.ts,apps/server/src/orchestration-v2/CheckpointCaptureService.test.tsEstimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Possibly related issues
Suggested reviewers:
juliusmarminge,voltcrashMerge Risk:
Moderate · up to
862c1The change reduces repeated 30-second Git timeouts for queued checkpoints in a shared folder. Some timeout cases may still probe repeatedly, and some recoveries may return an error checkpoint. These are bounded edge cases, but they should be resolved or accepted before merge.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the main change: queued messages no longer wait through every timed-out checkpoint in a shared folder. It follows the conventional commit form and matches the objective of skipping same-folder probes after a timeout. The title is specific and accurate for the changeset.
Full details: Description check
Explanation
The description covers the problem, the change, the scope, and the verification. The Problem section gives the symptom and the trace evidence. The Change section explains the streak check and the error checkpoint. The Scope section does not link an issue or say why none is needed, and the template asks for that. The Verification section gives focused test results and a check command. It does not name the 0.1.11 macOS environment as a template item, but it does include it in the problem context. The description also omits the agent model line in the required form, but it does include a Claude Opus attribution. The missing issue link or no-issue justification keeps this from a full match, but the description is mostly complete.
Resolution
Add a link to the issue that shows the bug, or state why a small fix needs no issue. Consider stating the reproduction environment explicitly in the Problem section.
Finishing Touches
Generate unit tests (beta)