mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-19 04:00:38 +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();
|
await gateway.close();
|
||||||
}
|
}
|
||||||
}, 20_000);
|
}, 20_000);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import {
|
||||||
projects,
|
projects,
|
||||||
projectWorkspaces,
|
projectWorkspaces,
|
||||||
} from "@paperclipai/db";
|
} from "@paperclipai/db";
|
||||||
import { conflict, notFound } from "../errors.js";
|
import { conflict, HttpError, notFound } from "../errors.js";
|
||||||
import { logger } from "../middleware/logger.js";
|
import { logger } from "../middleware/logger.js";
|
||||||
import { publishLiveEvent } from "./live-events.js";
|
import { publishLiveEvent } from "./live-events.js";
|
||||||
import { getRunLogStore, type RunLogHandle } from "./run-log-store.js";
|
import { getRunLogStore, type RunLogHandle } from "./run-log-store.js";
|
||||||
|
|
@ -787,6 +787,10 @@ function shouldAutoCheckoutIssueForWake(input: {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isCheckoutConflictError(error: unknown): boolean {
|
||||||
|
return error instanceof HttpError && error.status === 409 && error.message === "Issue checkout conflict";
|
||||||
|
}
|
||||||
|
|
||||||
function deriveCommentId(
|
function deriveCommentId(
|
||||||
contextSnapshot: Record<string, unknown> | null | undefined,
|
contextSnapshot: Record<string, unknown> | null | undefined,
|
||||||
payload: Record<string, unknown> | null | undefined,
|
payload: Record<string, unknown> | null | undefined,
|
||||||
|
|
@ -2704,8 +2708,13 @@ export function heartbeatService(db: Db) {
|
||||||
agentId: agent.id,
|
agentId: agent.id,
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
await issuesSvc.checkout(issueId, agent.id, ["todo", "backlog", "blocked"], run.id);
|
try {
|
||||||
context[PAPERCLIP_HARNESS_CHECKOUT_KEY] = true;
|
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);
|
issueContext = await getIssueExecutionContext(agent.companyId, issueId);
|
||||||
}
|
}
|
||||||
const issueAssigneeOverrides =
|
const issueAssigneeOverrides =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue