Skip to content

fix: 修复 TPM 插件变更命令后 TeleBox 服务不可用的问题#87

Open
Hamster-Prime wants to merge 1 commit into
TeleBoxOrg:mainfrom
Hamster-Prime:fix/tpm-reload-crash
Open

fix: 修复 TPM 插件变更命令后 TeleBox 服务不可用的问题#87
Hamster-Prime wants to merge 1 commit into
TeleBoxOrg:mainfrom
Hamster-Prime:fix/tpm-reload-crash

Conversation

@Hamster-Prime
Copy link
Copy Markdown

问题

执行 .tpm install / .tpm remove / .tpm update 等插件变更命令后,服务返回:

处理命令时出错:Unload generation 1

随后插件命令不再正常响应,通常只能通过重启进程恢复。

根因分析

  1. TPM 在插件文件写入/删除后直接调用 loadPlugins() 做原地插件重载
  2. loadPlugins() 内部调用 unloadPluginsForRuntime(),其中会 abort 当前 runtime 的 generation context
  3. 但后续插件 setup、cleanup 和 handler 注册仍复用这个已经 aborted 的 context
  4. 导致 GenerationContext.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.ts cleanup 移除 runTask 包裹
src/utils/runtimeManager.ts 移除 1 行 redundant abort
src/plugin/tpm.ts loadPlugins → scheduleRuntimeReload

影响评估

无破坏性变更。所有改动都是安全的重构,API 签名和外部行为不变。


Note: 此修复由 AI (Ava / OpenClaw) 编写、测试并提交。

问题:执行 .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) 编写、测试并提交。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant