Skip to content

fix: API 分页速率限制 + 429 检测#2

Open
alloevil wants to merge 1 commit into
mainfrom
fix/api-rate-limiting
Open

fix: API 分页速率限制 + 429 检测#2
alloevil wants to merge 1 commit into
mainfrom
fix/api-rate-limiting

Conversation

@alloevil

@alloevil alloevil commented Jul 8, 2026

Copy link
Copy Markdown
Owner

问题

auto-archive-simple.js 的 API 分页逻辑存在速率限制风险:

  • 500 页 × 300ms 间隔 = 2.5 分钟内发 500 次请求,无任何错误检测
  • 无 429/403 响应处理,无指数退避
  • 微博 API 有速率限制,可能导致账号被封

修复

  • ✅ 检测 HTTP 429/403 响应,触发指数退避(1s → 2s → 4s → 8s → 16s)
  • ✅ 检测微博业务错误码(10023/10024 频率限制,21301 登录失效)
  • ✅ 连续错误计数器,达 5 次自动停止(防止无限重试)
  • ✅ 基础间隔从 300ms 提升到 500ms
  • ✅ 每 50 页额外休息 2s
  • ✅ 被限流时不递增 pageNum,重试当前页

影响

归档行为不变,但遇到限流时会自动降速而非硬冲。

- Detect HTTP 429/403 responses with exponential backoff (1s→16s)
- Detect Weibo business error codes (10023/10024 frequency limits)
- Detect auth expiry (error_code 21301) and stop gracefully
- Add consecutive error counter with MAX_CONSECUTIVE_ERRORS=5 cutoff
- Increase base delay from 300ms to 500ms
- Add extra 2s rest every 50 pages
- Replace bare catch-retry with proper backoff strategy

Previous behavior: 500 requests at 300ms intervals with no error
handling could trigger Weibo's rate limiter and risk account suspension.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant