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