From 8848e396cf8ddb22e9c96286a6ca8184765eb791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iwo=20Strzebo=C5=84ski?= Date: Sun, 18 Oct 2026 20:00:00 +0000 Subject: [PATCH] Log the reason a late command result carries The warning for a result with no pending command discarded `ok` and `error` and said only that the id was unknown or expired - which is exactly the information the gateway now sends when a long-running command fails after being acknowledged. A `start_print` can only ever report its real outcome late, since it is answered on acceptance and this side times out after ten seconds. Nothing else changes: the job never reaching `printing` is what fails it. This is the difference between an operator seeing "job failed" and seeing which half of a download-then-upload failed and what the printer said. --- src/routes/ws/edge.ts | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/routes/ws/edge.ts b/src/routes/ws/edge.ts index 14c0aad..b19c437 100644 --- a/src/routes/ws/edge.ts +++ b/src/routes/ws/edge.ts @@ -501,11 +501,26 @@ export const edgeWsRoute = new Elysia() case "command_result": { const pending = conn.pending.get(message.command_id); if (!pending) { - // Either the command already timed out, or this gateway answered - // something we never asked. Both are worth saying out loud. + // Three ways to get here, and the third is the useful one. + // + // The command timed out; or this gateway answered something we + // never asked; or a long-running command that was acknowledged + // up front has now actually failed, and this is the gateway + // telling us why. A `start_print` is answered the moment it is + // accepted, because the transfer takes minutes and this side + // gives up after ten seconds - so its real outcome can only ever + // arrive late. + // + // The reason is logged rather than dropped. It is the difference + // between an operator seeing "job failed" and seeing which half + // of a download-then-upload failed and what the printer said. + // It does not change the job's fate: the job never reaching + // `printing` is what fails it, and that already works. Recording + // it against the job needs a column print_jobs does not have. + const reason = message.ok ? "reported success" : `failed: ${message.error ?? "no reason given"}`; console.warn( - `[edge] gateway ${conn.gatewayId} sent a result for unknown or ` + - `expired command ${message.command_id}`, + `[edge] gateway ${conn.gatewayId} sent a result for unknown, ` + + `expired or already-answered command ${message.command_id} - ${reason}`, ); return; }