fix(retry): avoid CPU busy wait

This commit is contained in:
xixu-me committed 2026-08-19 16:23:36 +08:00
1 parent 122ccef059
commit 21d87b184c
2 files changed
+5 -15

No files matched your search

+2 -14
View File
@@ -169,20 +169,8 @@ export async function checkRateLimit(
* @param seconds - Number of seconds to delay
* @returns Promise that resolves after the specified delay
*/
export async function delayRequest(seconds: number): Promise<void> {
return new Promise((resolve) => {
// Use a simple delay implementation for Workers environment
const start = Date.now();
const checkTime = () => {
if (Date.now() - start >= seconds * 1000) {
resolve();
} else {
// Use minimal delay to prevent blocking
Promise.resolve().then(checkTime);
}
};
checkTime();
});
export function delayRequest(seconds: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
}
/**