const registry = new Set(); export async function ensureSingleProcessOnly( token: string, bucket: string, fn: () => Promise, throttledError: Error ): Promise { const key = `${token}${bucket}`; if (registry.has(key)) { throw throttledError; } try { registry.add(key); const res = await fn(); return res; } finally { registry.delete(key); } }