Skip to content

Commit 8cd52c4

Browse files
pirateclaude
andcommitted
Worker: force=1 bypasses the dedup cache
The 6h dedup cache was blocking manual refresh-button dispatches. GitHub Actions' concurrency.group already serializes runs (1 active + 1 queued max per group) so rapid double-clicks are harmless. Keep the dedup only for the loading-page auto-dispatch path, which is the one that needs bot/scrape protection. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4699145 commit 8cd52c4

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

cloudflare/worker/index.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,25 @@ async function handleRefresh(
8989
}
9090
}
9191

92-
// Dedup: don't re-dispatch within ~6 hours of the most recent one for
93-
// this user. Uses Workers Cache API — no KV/DO binding needed.
92+
// Dedup: for non-force calls (loading page after initial visit), don't
93+
// re-dispatch within ~6 hours of the most recent one for this user.
94+
// Force calls (manual "Refresh stats" button) bypass dedup — GitHub
95+
// Actions' own concurrency.group keeps at most one queued run, which
96+
// is plenty of protection against rapid double-clicks.
9497
const cache = caches.default;
9598
const dedupKey = new Request(
9699
`https://internal-dedup.invalid/dispatch/${user}`,
97100
);
98-
const existing = await cache.match(dedupKey);
99-
if (existing) {
100-
return json({
101-
ok: true,
102-
user,
103-
status: "already_running",
104-
dispatched_at: existing.headers.get("X-Dispatched-At") ?? null,
105-
}, 202);
101+
if (!force) {
102+
const existing = await cache.match(dedupKey);
103+
if (existing) {
104+
return json({
105+
ok: true,
106+
user,
107+
status: "already_running",
108+
dispatched_at: existing.headers.get("X-Dispatched-At") ?? null,
109+
}, 202);
110+
}
106111
}
107112

108113
const repo = env.GH_REPO ?? "ArchiveBox/githubusers";

0 commit comments

Comments
 (0)