mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
Handle harness checkout conflicts gracefully
This commit is contained in:
parent
be82a912b2
commit
8e82ac7e38
2 changed files with 13 additions and 3 deletions
|
|
@ -574,4 +574,5 @@ describe("heartbeat comment wake batching", () => {
|
|||
await gateway.close();
|
||||
}
|
||||
}, 20_000);
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import {
|
|||
projects,
|
||||
projectWorkspaces,
|
||||
} from "@paperclipai/db";
|
||||
import { conflict, notFound } from "../errors.js";
|
||||
import { conflict, HttpError, notFound } from "../errors.js";
|
||||
import { logger } from "../middleware/logger.js";
|
||||
import { publishLiveEvent } from "./live-events.js";
|
||||
import { getRunLogStore, type RunLogHandle } from "./run-log-store.js";
|
||||
|
|
@ -787,6 +787,10 @@ function shouldAutoCheckoutIssueForWake(input: {
|
|||
return true;
|
||||
}
|
||||
|
||||
function isCheckoutConflictError(error: unknown): boolean {
|
||||
return error instanceof HttpError && error.status === 409 && error.message === "Issue checkout conflict";
|
||||
}
|
||||
|
||||
function deriveCommentId(
|
||||
contextSnapshot: Record<string, unknown> | null | undefined,
|
||||
payload: Record<string, unknown> | null | undefined,
|
||||
|
|
@ -2704,8 +2708,13 @@ export function heartbeatService(db: Db) {
|
|||
agentId: agent.id,
|
||||
})
|
||||
) {
|
||||
await issuesSvc.checkout(issueId, agent.id, ["todo", "backlog", "blocked"], run.id);
|
||||
context[PAPERCLIP_HARNESS_CHECKOUT_KEY] = true;
|
||||
try {
|
||||
await issuesSvc.checkout(issueId, agent.id, ["todo", "backlog", "blocked"], run.id);
|
||||
context[PAPERCLIP_HARNESS_CHECKOUT_KEY] = true;
|
||||
} catch (error) {
|
||||
if (!isCheckoutConflictError(error)) throw error;
|
||||
context[PAPERCLIP_HARNESS_CHECKOUT_KEY] = false;
|
||||
}
|
||||
issueContext = await getIssueExecutionContext(agent.companyId, issueId);
|
||||
}
|
||||
const issueAssigneeOverrides =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue