Repository navigation
fix(fleet-supervisor): 防止维护窗口等待期间 supervisor 自行退出 - #3850
Merged
Merged
Conversation
Co-Authored-By: Kimi <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 25, 2026 18:02
Owner
Author
评审结论(head
|
This was referenced Nov 26, 2026
|
🚀 Released in v3.59.35 |
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.
Fixes #3728
根因
维护窗口激活时,
FleetSupervisor.spawnBot将 daemon 的首次启动或重启延后 1 秒,但对 deferral timer 调用了unref()。单成员 fleet 中没有其他存活 child 或 ref 句柄时,事件循环会直接 drain,supervisor 以 code 0 自然退出,维护结束后也无法再拉起 daemon。崩溃重试分支已经明确要求 timer 保持 ref;维护 deferral 分支与其不一致。
修改
unref(),与崩溃重试保持相同的保活语义。restartTimers;stopAll()/stopOneBot()沿用现有clearTimeout路径,正常停机不会因新增 ref 而挂起。影响面
仅改变
entry === 'daemon'且 feedback maintenance 激活时的 deferral timer 保活方式。dashboard、external/plugin 成员不经过该分支;CLI 适配器、PTY/Tmux 后端、IM 协议、配置和持久化 schema 均未改动。多成员 fleet 行为不变,无配置迁移或用户侧 break change。验证
bun run build:通过。isolate-run --timeout 10m -- bun run test -- test/fleet-supervisor.integration.test.ts test/fleet-supervisor-maintenance.test.ts:2 个文件、59 项全部通过。isolate-run --timeout 10m -- bash -c 'bun test test/fleet-supervisor.integration.test.ts && bun test test/fleet-supervisor-maintenance.test.ts':既有 54 项 + 新增 5 项全部通过。bun run test -- test/test-hygiene.test.ts:28 项全部通过。launching,均按预期变红。stopAll()/stopOneBot()的clearTimeout,fake timer 用例均从 0 变成 1 并咬红。异常时序与失败注入复核
已覆盖维护等待中的 stop/start/reconcile、deferral tick 与停止交叠、维护结束后的拉起、单成员 Node/Bun 事件循环,以及停止后的定时器清理;未发现本次改动引入的新问题。
失败注入另发现一项既有边界(本 PR 未改变):
stopOneBot在取消 pending timer 后,如果最终停止状态的原子写入失败,drainCommands记录错误后,Node 与 Bun 探针均观察到单成员进程触发beforeExit,磁盘保留launching和旧 supervisor 身份。该路径与 crash backoff 共用,并非本 PR 引入。建议后续单独设计写失败后的 retry / ownership 清理,同时覆盖 crash backoff,避免在本次定向修复中改变既有持久化错误语义。🤖 Generated with Claude Code