From c7eaf3edd05c4f0d60100f729859d764937319c8 Mon Sep 17 00:00:00 2001 From: spark Date: Mon, 19 Oct 2026 15:03:15 +0100 Subject: [PATCH] Let a busy edit wait for the database instead of failing. Sixteen photos writing at once were hitting the five-second transaction limit, so a few edits were dropped. The write now waits up to twenty seconds for a connection and to finish. --- apps/api/src/develop/service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/api/src/develop/service.ts b/apps/api/src/develop/service.ts index dee8820..787c21b 100644 --- a/apps/api/src/develop/service.ts +++ b/apps/api/src/develop/service.ts @@ -73,6 +73,7 @@ export class DevelopService { async append(photoId: string, userId: string | null, body: PostEdits): Promise<{ developSeq: number; ops: EditLogEntry[] }> { for (const op of body.ops) validate(op.command); const { db, broadcaster } = this.deps; + // Many photos are edited at once. Waiting for a connection must not drop the edit. const result = await db.$transaction(async (tx) => { const [locked] = await tx.$queryRaw<{ develop_seq: number; organization_id: string; event_id: string | null }[]>` SELECT develop_seq, organization_id, event_id FROM photos WHERE id = ${photoId}::uuid FOR UPDATE`; @@ -100,7 +101,7 @@ export class DevelopService { } if (fresh.length) await tx.photo.update({ where: { id: photoId }, data: { developSeq: seq, editedAt: new Date(), renderStatus: "PENDING" } }); return { organizationId: locked.organization_id, eventId: locked.event_id, developSeq: seq, out, fresh }; - }); + }, { maxWait: 20_000, timeout: 20_000 }); if (result.fresh.length && body.clientId !== "autopilot") this.deps.onHumanEdit?.(photoId); if (result.fresh.length) { broadcaster.library(result.organizationId, { -- 2.47.3