Repository navigation
fix(workflow-console): 一次探活失败不再把引擎永久打成离线 - #206
Merged
MyPrototypeWhat merged 1 commit intoDec 4, 2026
Merged
Conversation
refreshEmbedded() 的 catch 把 record.live 置成 false,而同一个函数第一行的 !record.live 又让它从此再也不探活。引擎进程其实还活着、还在正常服务,控制台 却一直显示离线,业务接口也报「没有可用后端」——只有等宿主重启 Node 进程才 能恢复。控制台入口 startEmbedded() 也因为 engineReady 是个已 resolve 的 promise 而不会重拉。 探活失败现在不再是终态:门禁改成「有地址才探」,探通时把 live 置回 true、 清掉上次失联的原因。为了不让死掉的引擎把每次请求都拖成 3 秒超时,失败之后 有 5 秒冷却期;窗口一过就重新探,引擎回来了自己会回来。 新增 tests/engine-liveness.test.mjs:假 /api/config 上游,先正常、再报 500、 再恢复,断言 live 从 true 掉到 false 再回到 true。未改代码上红(30 秒后仍是 离线),改完绿。 版本号 1.2.1。
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.
控制台一次探活超时之后,引擎就再也回不来了。
refreshEmbedded()的 catch 分支把record.live置成 false,而同一个函数第一行的!record.live又让它从此永远提前返回、再也不探活;成功分支里也没有把 live 置回 true 的代码。startEmbedded()开头是if (engineReady) return engineReady;—— engineReady 是个已 resolve 的 promise,所以它返回的是那条旧记录,既不重拉也不重探;/api/bootstrap里的if (!engineReady && ...)同理不成立。引擎进程其实还活着、还在正常服务,控制台却一直显示离线,业务接口走
liveService()拿到的也是 live=false 的记录,返回 null,报「没有可用后端」。只有等宿主重启 Node 进程才能恢复。实测(未改的代码,30 秒后):
改的是探活失败不再是终态:门禁从「live 才探」改成「有地址才探」,探通时把 live 置回 true 并清掉上次失联的原因。为了不让死掉的引擎把每个请求都拖成 3 秒超时,失败之后有 5 秒冷却期;窗口一过就重新探,引擎回来了自己会回来。
新增
tests/engine-liveness.test.mjs:假的/api/config上游,先正常、再报 500、再恢复,断言 live 从 true 掉到 false 再回到 true。未改的代码上红(30 秒后仍是离线),改完绿。插件自带测试 17/17,仓库根npm run check0 error。版本号 1.2.1。
验证范围:只有 Node 22 上的测试是实测的。真实 Host 和 Electron 我没跑过 —— 这一层是仅个人判断。
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.