fix: 修复 TPM 插件变更命令后 TeleBox 服务不可用的问题#87
Open
Hamster-Prime wants to merge 1 commit into
Open
Conversation
问题:执行 .tpm install / .tpm remove / .tpm update 等插件变更命令后, 服务返回 "Unload generation 1" 错误,插件命令不再响应,通常需要重启恢复。 根因: 1. TPM 在插件文件写入/删除后直接调用 loadPlugins() 做原地重载 2. loadPlugins() 内部的 unloadPluginsForRuntime() 会 abort 当前 generation context,但后续 setup/cleanup/handler 注册仍复用这个 已 aborted 的 context,导致 GenerationContext.runTask() 拒绝执行 修复: - pluginManager: runPluginCleanup 移除 runtime.context.runTask() 包裹, 避免 cleanup 在 context 已 abort 后被拒绝执行 - runtimeManager: reloadRuntime 移除 redundant 的 oldRuntime.context.abort() 调用(buildRuntime 已创建全新 context) - tpm: 所有 loadPlugins() 替换为 scheduleRuntimeReload()(延迟执行 reloadRuntime()),走完整的 runtime 生命周期重载,避免复用已 abort 的 generation 此修复由 AI (Ava / OpenClaw) 编写、测试并提交。
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.
问题
执行
.tpm install/.tpm remove/.tpm update等插件变更命令后,服务返回:随后插件命令不再正常响应,通常只能通过重启进程恢复。
根因分析
loadPlugins()做原地插件重载loadPlugins()内部调用unloadPluginsForRuntime(),其中会abort当前 runtime 的 generation contextGenerationContext.runTask()直接拒绝执行,并把 abort reason 作为错误抛出修复方案
pluginManager.ts
runPluginCleanup移除runtime.context.runTask()包裹,改为直接调用plugin.cleanup(),避免 cleanup 在 context 已 abort 后被拒绝执行。runtimeManager.ts
reloadRuntime()移除 redundant 的oldRuntime.context.abort("Runtime reload")调用,因为buildRuntime()已创建全新 context,不需要再手动 abort 旧的。tpm.ts
所有
loadPlugins()调用替换为scheduleRuntimeReload()(通过setTimeout(0)延迟执行reloadRuntime()),走完整的 runtime 生命周期重载:卸载旧插件 → 释放旧 runtime → 创建新 runtime → 重新加载插件,避免复用已 abort 的 generation。变更范围
src/utils/pluginManager.tssrc/utils/runtimeManager.tssrc/plugin/tpm.ts影响评估
无破坏性变更。所有改动都是安全的重构,API 签名和外部行为不变。