fix: 防止 HWPOD operation 重复派发

This commit is contained in:
root
2026-07-17 04:19:31 +02:00
parent ab76290e9d
commit 84dc6618e6
6 changed files with 197 additions and 19 deletions
+8
View File
@@ -32,6 +32,14 @@ const DEFAULT_BODY_LIMIT_BYTES = 1024 * 1024;
export async function handleHwpodNodeOpsHttp(request, response, options) {
if (request.method === "GET") {
const planId = new URL(request.url, "http://hwlab.local").searchParams.get("planId")?.trim() ?? "";
if (planId) {
const operation = options.hwpodNodeWsRegistry.lookup(planId);
sendJson(response, operation ? 200 : 404, operation
? { ok: true, status: operation.result ? "completed" : "running", contractVersion: HWPOD_NODE_OPS_CONTRACT_VERSION, ...operation }
: { ok: false, status: "not-found", contractVersion: HWPOD_NODE_OPS_CONTRACT_VERSION, planId, error: { code: "hwpod_operation_not_found", message: `hwpod operation ${planId} was not found` } });
return;
}
sendJson(response, 200, {
ok: true,
status: "ready",