feat: mutual friend graph (#1491)

This commit is contained in:
pa
2025-11-18 23:30:00 +09:00
committed by Natsumi
parent 0bc9980cae
commit 424edb04e0
12 changed files with 1073 additions and 35 deletions

24
src/shared/utils/retry.js Normal file
View File

@@ -0,0 +1,24 @@
export async function executeWithBackoff(fn, options = {}) {
const {
maxRetries = 5,
baseDelay = 1000,
shouldRetry = () => true
} = options;
async function attempt(remaining) {
try {
return await fn();
} catch (err) {
if (remaining <= 0 || !shouldRetry(err)) {
throw err;
}
const delay =
baseDelay *
Math.pow(2, (options.maxRetries || maxRetries) - remaining);
await new Promise((resolve) => setTimeout(resolve, delay));
return attempt(remaining - 1);
}
}
return attempt(maxRetries);
}