Repository navigation
fix(web-record): 导出失败加退避与熔断,别把控制台和主线程刷爆 - #7
Merged
Merged
Conversation
现场(2026-08-25,甲方内网):到不了配置的 collector,原实现每 5 秒把同一批 事件原样重发,失败 429 次没停过。后果不只是日志难看: - 控制台 429 条同样的 error,把真正有用的报错淹了; - 每一轮都白做一次 JSON.stringify + 压缩(最多 500 条 rrweb 事件), 主线程被反复占用,页面肉眼可见地卡; - 宿主 SPA 每次路由变化都会调 record(),失败态下等于反复重新武装。 四条对策: 1. 连败指数退避(5s→10s→20s…封顶 5 分钟),挡在定时器层。flush() 本身 语义不变——直接调仍然立即尝试,drainFlush/stop 的行为没动。 2. 连败到 5 次熔断:停采集、清缓冲,并打一条写明端点和处置办法的日志 (封闭环境该去设 SOFTPROBE_BASE_URL,而不是让它一直重试)。 3. 只在连败的第一条打日志,后续静默——日志本身就是故障放大器。 4. 熔断后 record() 拒绝重新武装。 单次失败仍然保留缓冲(可能只是网络抖动),这一点刻意不改。 测试:新增 4 条,在旧实现上全红(4 failed / 8 passed),新实现 12 全绿; 既有 8 条(含 keeps buffer when flush fails)自始至终绿,原语义没被动。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
现象
甲方内网现场(2026-08-25):浏览器控制台 868 条 error,其中 429 条是同一句
[@softprobe/web-record] Failed to flush recording;页面刷新要 1.8 分钟才 finish,请求大量(canceled) 0 B。原因
collector 不可达时,原实现每 5 秒把同一批事件原样重发,永不放弃:
JSON.stringify+ 压缩(最多 500 条 rrweb 事件),主线程被反复占用;record(),失败态下等于反复重新武装采集。改了什么
flush()本身语义不变——直接调仍然立即尝试,drainFlush/stop()行为没动SOFTPROBE_BASE_URL)record()拒绝重新武装刻意没改:单次失败仍然保留缓冲(可能只是网络抖动)。
测试
新增 4 条。先红后绿都验过:
既有 8 条(含
keeps buffer when flush fails)自始至终绿 —— 原语义没被动。🤖 Generated with Claude Code