fix(VCPClawMail): prevent short-lived WS connections from resetting retry backoff#413
Merged
lioensky merged 1 commit intoJul 19, 2026
Conversation
…etry backoff; add jitter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
VCPClawMail 的 WebSocket 即达监听在连接短暂成功后快速断开(如 CONNACK 后 2~3 秒收到 1006)时,
会立即将
state.retries归零,导致退避数组 [1s, 2s, 5s, 10s, 30s, 60s] 永远停留在首档。五个邮箱账号使用完全相同的固定延迟,同步断线后形成锁相惊群式重连风暴。
修复内容
移除 CONNACK 后立即清零 retries 的逻辑
connectedAtMs时间戳,不再认为握手 = 稳定。在断开回调中按 uptime 判断是否清零
WS_STABLE_CONNECTION_MS),认为旧失败已过时,清零 retries。为重连延迟加入有限 jitter
stopWsListeners 清除
connectedAtMs测试
node --check语法验证通过。未解决
timeDiff的 uint64 回绕仅为日志现象,不参与重连决策。说来,由于难以对网易邮箱的连接逻辑进行完美匹配,本次修改只是尝试增加了鲁棒性。
以我的观感,似乎是如果node进程被同步占据了一段时间后,直接强制用pm2命令重启,会比较容易出现这个问题。而且,出现这个问题后,只是restart似乎没法解决,非要kill后再度启动才能解决(存疑)。
附带改动
Plugin.js:我自己的某个插件开发,需要只读知识库,于是加了一行通用性质的代码,或许是可以merge的。这与本次 WebSocket 修复无逻辑依赖。