UNPKG

appwrite-utils-cli

Version:

Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.

22 lines (21 loc) 718 B
export const retryFailedPromises = async (batch, maxRetries = 3) => { const results = await Promise.allSettled(batch); const toRetry = []; results.forEach((result, index) => { if (result.status === "rejected") { console.error("Promise rejected with reason:", result.reason); if (maxRetries > 0) { toRetry.push(batch[index]); } } }); if (toRetry.length > 0) { console.log(`Retrying ${toRetry.length} promises`); return retryFailedPromises(toRetry, maxRetries - 1); } else { return results .filter((result) => result.status === "fulfilled") .map((result) => result); } };