From 4448688102e5fe978cf980d71f7d434766f44db5 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 16 Sep 2026 23:39:59 +0200 Subject: [PATCH] fix: a restarted modification is retried, not regenerated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit recoverResourceJobs marked every interrupted job failed with "The server restarted while this was being written. Generate it again." It matches all kinds, so someone whose modification was interrupted was told to generate — which makes a new resource rather than retrying the edit they asked for, and leaves the deck they were changing unmodified. The message is the only guidance they get, so it now names the action that actually helps. --- src/routes/myResources.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/routes/myResources.js b/src/routes/myResources.js index 068726e2..94cf6a5e 100644 --- a/src/routes/myResources.js +++ b/src/routes/myResources.js @@ -617,8 +617,13 @@ async function runResourceJob(jobId, userId, body, kind, resourceId) { // leave "Writing…" on the page for ever. async function recoverResourceJobs() { try { + // Kind-aware, because "Generate it again" is the wrong instruction for a + // modification: generating makes a new resource, it does not retry the edit + // the person asked for. This message is the only guidance they get. var n = await db.run("UPDATE user_resource_jobs SET status = 'failed', finished_at = NOW(), " + - "error = 'The server restarted while this was being written. Generate it again.' " + + "error = CASE WHEN kind = 'refine' " + + "THEN 'The server restarted before this change was applied. Try the change again.' " + + "ELSE 'The server restarted while this was being written. Generate it again.' END " + "WHERE status IN ('queued', 'running')"); if (n && n.changes) logger.warn('[my-resources] ' + n.changes + ' job(s) were interrupted by a restart'); } catch (err) { console.error('[my-resources] job recovery:', err.message); }