Skip to content

Commit 845d45d

Browse files
committed
update shouldRetry429 condition
1 parent cba3873 commit 845d45d

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

packages/filesystem/limiter.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export class RateLimiter {
5656
return await fn();
5757
} catch (error) {
5858
// 检查错误字符串中是否包含 429
59-
const errorStr = String(error);
60-
if (this.shouldRetry429(op, errorStr) && i < 10) {
59+
const errorStr = String(error).toLowerCase();
60+
if (this.shouldRetry429(op, ` ${errorStr} `) && i < 10) {
6161
// 遇到 429 错误且未达到重试上限,采用指数退避策略延迟后继续重试
6262
const delay = Math.min(2000 * Math.pow(2, i), 60000);
6363
await new Promise((resolve) => setTimeout(resolve, delay));
@@ -73,8 +73,7 @@ export class RateLimiter {
7373

7474
private shouldRetry429(op: string, errorStr: string): boolean {
7575
return (
76-
((errorStr.includes("429") && /[^A-Za-z\d]429[^A-Za-z\d]/.test(` ${errorStr} `)) ||
77-
errorStr.toLowerCase().includes("too many requests")) &&
76+
((errorStr.includes("429") && /[^a-z\d]429[^a-z\d]/.test(errorStr)) || errorStr.includes("too many requests")) &&
7877
RETRYABLE_429_OPS.has(op)
7978
);
8079
}

0 commit comments

Comments
 (0)