Refactor: drop Bun.nanoseconds & Bun.sleep

This commit is contained in:
SukkaW
2024-07-23 15:53:10 +08:00
parent b1481c87f2
commit e0e79c9fe5
4 changed files with 11 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
import retry from 'async-retry';
import picocolors from 'picocolors';
import { setTimeout } from 'timers/promises';
// retry settings
const MIN_TIMEOUT = 10;
@@ -84,7 +85,7 @@ function createFetchRetry($fetch: typeof fetch): FetchWithRetry {
if (retryAfter > retryOpts.maxRetryAfter) {
return res;
}
await Bun.sleep(retryAfter * 1e3);
await setTimeout(retryAfter * 1e3, undefined, { ref: false });
}
}
throw new ResponseError(res);