feat(sync): harden the Hiboutik sync, share rate limits across instances, update dependencies (#4)
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { rethrowIfRateLimited } from '../hiboutik/hiboutik.client';
|
||||
|
||||
/**
|
||||
* Runs `action` on each item, one at a time: a failing item is logged and skipped, the others are still processed.
|
||||
* A Hiboutik rate limit error stops the loop (rethrown): the next items would fail the same way.
|
||||
* @param items
|
||||
* @param action
|
||||
* @param logger
|
||||
@@ -19,6 +21,7 @@ export async function forEachSafely<T>(
|
||||
try {
|
||||
await action(item);
|
||||
} catch (error) {
|
||||
rethrowIfRateLimited(error);
|
||||
nbFailed++;
|
||||
logger.error(`Failed to sync ${describe(item)}`, (error as Error)?.stack);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user