Archived
fix: handle long-running executor prompts
This commit is contained in:
@@ -6,6 +6,7 @@ import { GiteaClient } from "../../adapters/gitea/client/client.js";
|
||||
import { findAcceptedPlan } from "../../adapters/gitea/issues.js";
|
||||
import {
|
||||
formatError,
|
||||
log,
|
||||
protocolVersion,
|
||||
type Result,
|
||||
} from "../../core/contracts.js";
|
||||
@@ -117,6 +118,7 @@ async function executePlan(
|
||||
},
|
||||
});
|
||||
input.store.finishExecution(input.job.id, input.worker, output.result);
|
||||
logCompletion(input, output.result);
|
||||
}
|
||||
|
||||
async function executeImplementation(
|
||||
@@ -162,6 +164,20 @@ async function executeImplementation(
|
||||
},
|
||||
});
|
||||
input.store.finishExecution(input.job.id, input.worker, output.result);
|
||||
logCompletion(input, output.result);
|
||||
}
|
||||
|
||||
function logCompletion(
|
||||
input: Parameters<typeof executeJob>[0],
|
||||
result: Result,
|
||||
): void {
|
||||
console.log(
|
||||
log("info", "Execution completed", {
|
||||
jobId: input.job.id,
|
||||
mode: input.job.mode,
|
||||
status: result.status,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async function handleFailure(
|
||||
@@ -173,11 +189,9 @@ async function handleFailure(
|
||||
input.shutdown.aborted ||
|
||||
!input.store.ownsLease(input.job.id, input.worker)
|
||||
) {
|
||||
console.error(
|
||||
JSON.stringify({
|
||||
level: "info",
|
||||
console.log(
|
||||
log("info", "Execution interrupted; lease will be recovered", {
|
||||
jobId: input.job.id,
|
||||
message: "Execution interrupted; lease will be recovered",
|
||||
}),
|
||||
);
|
||||
return;
|
||||
@@ -194,18 +208,16 @@ async function handleFailure(
|
||||
input.store.finishExecution(input.job.id, input.worker, result);
|
||||
} catch (finishError) {
|
||||
console.error(
|
||||
JSON.stringify({
|
||||
level: "error",
|
||||
log("error", "Execution finalization failed", {
|
||||
jobId: input.job.id,
|
||||
message: formatError(finishError),
|
||||
error: formatError(finishError),
|
||||
}),
|
||||
);
|
||||
}
|
||||
console.error(
|
||||
JSON.stringify({
|
||||
level: "error",
|
||||
log("error", "Execution failed", {
|
||||
jobId: input.job.id,
|
||||
message: formatError(error),
|
||||
error: formatError(error),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user