From ffc8fb0eeea905a154fa5012101936eb297f9ace Mon Sep 17 00:00:00 2001 From: openclaw Date: Sat, 25 Jul 2026 01:03:20 +0800 Subject: [PATCH] fix: back off conversion status polling --- apps/web/src/stores/entries.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/web/src/stores/entries.ts b/apps/web/src/stores/entries.ts index 8551971..993dcfc 100644 --- a/apps/web/src/stores/entries.ts +++ b/apps/web/src/stores/entries.ts @@ -10,12 +10,22 @@ let syncPromise: Promise | null = null; let syncTriggersStarted = false; let conversionPollTimer: number | null = null; let conversionPollAttempts = 0; +let conversionPollDeadline = 0; const conversionPollEntryIds = new Set(); function scheduleConversionPoll(entryIds: string[], resetAttempts = true) { for (const entryId of entryIds) conversionPollEntryIds.add(entryId); if (conversionPollTimer !== null || typeof window === "undefined") return; - if (resetAttempts) conversionPollAttempts = 0; + if (resetAttempts) { + conversionPollAttempts = 0; + conversionPollDeadline = Date.now() + 60_000; + } + const remainingMs = conversionPollDeadline - Date.now(); + if (remainingMs <= 0) { + conversionPollEntryIds.clear(); + return; + } + const delayMs = Math.min(1_500 * 2 ** conversionPollAttempts, remainingMs); const poll = async () => { conversionPollTimer = null; const store = useEntryStore(); @@ -25,11 +35,11 @@ function scheduleConversionPoll(entryIds: string[], resetAttempts = true) { store.entries.some((entry) => entry.id === entryId && entry.conversionStatus === "pending"), ); conversionPollEntryIds.clear(); - if (!remaining.length || conversionPollAttempts >= 6) return; + if (!remaining.length || Date.now() >= conversionPollDeadline) return; conversionPollAttempts += 1; scheduleConversionPoll(remaining, false); }; - conversionPollTimer = window.setTimeout(() => void poll(), 1_500); + conversionPollTimer = window.setTimeout(() => void poll(), delayMs); } export const useEntryStore = defineStore("entries", {