fix: improve artifact preflight remote polling
This commit is contained in:
@@ -568,9 +568,9 @@ async function waitForFrontendTask(session: FrontendSession, taskId: string, tim
|
||||
const started = Date.now();
|
||||
let latest: unknown = null;
|
||||
while (Date.now() - started < timeoutMs) {
|
||||
latest = await frontendJson(session, "/api/tasks?limit=100");
|
||||
const tasks = (latest as { body?: { tasks?: Array<{ id?: string; status?: string; result?: unknown }> } }).body?.tasks ?? [];
|
||||
const task = tasks.find((item) => item.id === taskId);
|
||||
latest = await frontendJson(session, `/api/tasks/${encodeURIComponent(taskId)}`, undefined, 8000, 5_000_000);
|
||||
const body = latest as { body?: { task?: { id?: string; status?: string; result?: unknown } } };
|
||||
const task = body.body?.task;
|
||||
if (task?.status === "succeeded" || task?.status === "failed") return { ok: true, task };
|
||||
await Bun.sleep(500);
|
||||
}
|
||||
@@ -656,7 +656,7 @@ function commandResultFromFrontendTask(command: string[], task: { status?: strin
|
||||
stdout,
|
||||
stderr,
|
||||
signal: null,
|
||||
timedOut: task?.status !== "succeeded" && stderr.includes("timeout"),
|
||||
timedOut: result.timedOut === true || (task?.status !== "succeeded" && /timeout|timed out/iu.test(stderr)),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -749,11 +749,15 @@ async function remoteCi(session: FrontendSession, config: UniDeskConfig, args: s
|
||||
};
|
||||
},
|
||||
commandCwd: ".",
|
||||
artifactRegistryCommand: (probe) => ["frontend", "/api/dispatch", probe.providerId, "host.ssh", probe.action],
|
||||
artifactRegistryCommand: (probe) => ["frontend", "/api/dispatch", probe.providerId, "host.ssh", probe.action, dispatchedTaskShape(probe.remoteCommandShape)],
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
function dispatchedTaskShape(remoteCommandShape: string): string {
|
||||
return remoteCommandShape.length > 0 ? remoteCommandShape : "host.ssh artifact-registry readonly probe";
|
||||
}
|
||||
|
||||
async function remoteCodeQueue(session: FrontendSession, args: string[]): Promise<unknown> {
|
||||
const action = args[1] ?? "task";
|
||||
if (action !== "task" && action !== "summary" && action !== "show" && action !== "tasks" && action !== "overview" && action !== "output" && action !== "judge") {
|
||||
|
||||
Reference in New Issue
Block a user