merge: a restarted modification is retried, not regenerated
Some checks failed
Forgejo Docker Build / Root app tests (push) Successful in 48s
Forgejo Docker Build / Build Docker image (push) Successful in 6s
Forgejo Docker Build / End-to-end (browser) (push) Failing after 7s

This commit is contained in:
Daniel 2026-09-16 23:39:59 +02:00
commit f3e4e6df4f

View file

@ -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); }