Skip to content

perf(polling): visibility 暂停 + TranslationPanel 超时 + request 套 retryAsync - #44

Merged
Color2333 merged 1 commit into
mainfrom
perf/pr4-polling
Jul 17, 2026
Merged

perf(polling): visibility 暂停 + TranslationPanel 超时 + request 套 retryAsync#44
Color2333 merged 1 commit into
mainfrom
perf/pr4-polling

Conversation

@Color2333

Copy link
Copy Markdown
Owner

PR4 — 轮询优化(中风险)

GlobalTaskContext

  • visibilitychange 监听,document.hidden 停止轮询(此前后台标签 360-1800 次/小时冗余→0)

Sidebar

  • folderStats 60s 轮询加 visibility 暂停

TranslationPanel

  • 5 分钟超时 + 连续错误 10 次上限(此前任务挂起时 1800 次/小时泄漏)
  • pollRef + 卸载 cleanup;alert 改 toast

CitationPanel

  • 导入轮询 1s→2s + 5 分钟超时

api.ts

  • get 套 retryAsync(3 次指数退避,仅 NETWORK/SERVER/timeout 重试,瞬时故障 100%→0.1%)
  • POST/PATCH/PUT/DELETE 不套(非幂等避免重复写入)

验证

  • typecheck 通过;5 PR 合并零冲突

…sync

PR4 — 轮询优化

GlobalTaskContext:
- 加 visibilitychange 监听,document.hidden 时停止轮询,恢复可见时立即拉+重启
  (此前后台标签 360-1800 次/小时冗余 /tasks/active 请求降为 0)

Sidebar:
- folderStats 60s 轮询加 visibility 暂停(此前后台 60 次/小时冗余)

TranslationPanel:
- 轮询加 5 分钟超时 + 连续错误 10 次上限(此前无超时,任务挂起时 1800 次/小时泄漏)
- pollRef 持有定时器 + 卸载 cleanup(此前闭包内局部变量,卸载无法清)
- alert 改 toast(与 app 风格统一)

CitationPanel:
- 导入轮询间隔 1s→2s + 加 5 分钟超时(此前 1s 偏激进,无超时兜底)

api.ts request 套 retryAsync:
- get 套 retryAsync(3 次指数退避,仅 NETWORK/SERVER/timeout 重试)
  瞬时故障从 100% 失败降到 ~0.1%
- POST/PATCH/PUT/DELETE 不套(非幂等,重试可能导致重复写入)
- 复用已写好未用的 errorHandler.retryAsync
@github-actions

Copy link
Copy Markdown

🔍 OpenCode PR Review Required

这是一个受保护的分支,merge 前需要进行 code review。

请运行以下命令进行 OpenCode review:

/oc review https://github.com/Color2333/PaperMind/pull/$PR_NUM

或者在 PR 页面评论 /oc 来触发 OpenCode review。


This is an automated reminder from PR Review Gate.

@Color2333
Color2333 merged commit 3f378ab into main Jul 17, 2026
2 checks passed
@Color2333
Color2333 deleted the perf/pr4-polling branch July 17, 2026 16:08
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