fix(desktop): wait for idle worker exit before restart (#3330) - #3344
fix(desktop): wait for idle worker exit before restart (#3330)#3344nothingyuancando wants to merge 3 commits into
Conversation
Signed-off-by: nothingyuancando <1579035512@qq.com>
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/cindy-brain/nodeRuntimeBroker.ts | 在停止与重新启动之间加入按 worker key 管理的有界退出屏障,并保留现有单飞启动机制。 |
| apps/desktop/src/main/cindy-brain/tests/nodeRuntimeBroker.test.ts | 新增旧进程延迟退出、并发请求共享屏障及超时后恢复启动的回归覆盖。 |
Sequence Diagram
sequenceDiagram
participant R as 后续请求
participant B as Node Runtime Broker
participant O as 旧 UtilityProcess
participant N as 新 UtilityProcess
B->>B: 从 workers 移除旧 worker
B->>B: 注册同 key 退出屏障
B->>O: SIGTERM
R->>B: 请求同 key worker
B->>B: 等待退出屏障
O-->>B: exit
B->>B: 清理退出屏障
B->>N: fork 替代进程
N-->>B: spawn / ready
B-->>R: 返回请求结果
Reviews (2): Last reviewed commit: "test(desktop): harden node worker exit b..." | Re-trigger Greptile
|
这个 PR 改了插件 worker 空闲回收后的重启时序,属于插件基座,已进入维护者确认(基座改动不因 bugfix 豁免)。 请维护者在本 PR 上 Approve;需要修改请 Request Changes。讨论 issue:#3351 |
|
Nice implementation — cleaner than my #3343 approach of using a custom I did an adversarial review and found 3 test gaps worth considering: 1. Concurrent requests during barrier waitThe most critical scenario the current test doesn't cover: two requests arrive while the old process is still exiting. Currently the test only verifies a single request waits for exit. But with two concurrent requests, both should share the same barrier and both should resolve to a single 2. Barrier timeout → eventual recoveryIf the barrier rejects (process didn't exit within grace period), the next request gets
This proves the system recovers after a timeout failure, not just fails permanently. 3.
|
|
CI update: This test is not related to your changes — it's a renderer-side test that doesn't touch You can verify by re-running the failed job, or pushing an empty commit to trigger a fresh CI run. |
Signed-off-by: nothingyuancando <1579035512@qq.com>
98e16a8 to
a308e16
Compare
这次改了什么
摘要
修复按需 Node worker 空闲回收后的同 key 重启竞态:worker 从业务表移除后,只有在旧 UtilityProcess 真实触发
exit后,才允许下一次请求 fork 替代进程;若旧进程在有界时间内未退出,返回停止失败而不双开。变更类型
fix缺陷修复feat新功能refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
pi-package-home或其它 worker 类型。UI 变化
不涉及 UI。
怎么验证的
自动验证
回归覆盖“首次请求 → 空闲停止 → 旧进程延迟退出 → 第二次请求”,并断言退出前不 fork 同 key 新进程。
手工验证
不涉及;真实 Windows packaged
utilityProcess.fork验证留给 CI/发布验收。未执行的验证
未在 Windows packaged 应用中执行现场复现;当前使用进程假体覆盖延迟退出、强杀屏障和同 key 重启时序。
风险
风险分类
影响与回滚
提交前检查
git commit -s,见 DCO)