Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { OutgoingRequest } from "@/generated/prisma/client";
import { Prisma, type OutgoingRequest } from "@/generated/prisma/client";
import { getExternalDbSyncFusebox } from "@/lib/external-db-sync-metadata";
import { upstash } from "@/lib/upstash";
import { globalPrismaClient, retryTransaction } from "@/prisma-client";
Expand Down Expand Up @@ -219,6 +219,17 @@ export const GET = createSmartRouteHandler({
} catch (error) {
processSpan.setAttribute("stack.external-db-sync.iteration-error", true);
captureError("poller-iteration-error", error);
// Reset claimed requests so they can be retried on the next iteration
// instead of staying stuck with startedFulfillingAt set
try {
await globalPrismaClient.$executeRaw`
UPDATE "OutgoingRequest"
SET "startedFulfillingAt" = NULL
WHERE "id" IN (${Prisma.join(requests.map(r => r.id))})
`;
} catch (resetError) {
captureError("poller-reset-claimed-requests", resetError);
}
processSpan.setAttribute("stack.external-db-sync.processed-count", 0);
return 0;
}
Expand Down
Loading