diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index 93512bde2..5f5157337 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -529,8 +529,19 @@ async def load( requirements_path=requirements_path, ) except Exception as e: - logger.error(traceback.format_exc()) + error_trace = traceback.format_exc() + logger.error(error_trace) logger.error(f"插件 {root_dir_name} 导入失败。原因:{e!s}") + fail_rec += f"加载 {root_dir_name} 插件时出现问题,原因 {e!s}。\n" + self.failed_plugin_dict[root_dir_name] = { + "error": str(e), + "traceback": error_trace, + } + if path in star_map: + logger.info("失败插件依旧在插件列表中,正在清理...") + metadata = star_map.pop(path) + if metadata in star_registry: + star_registry.remove(metadata) continue # 检查 _conf_schema.json @@ -784,6 +795,11 @@ async def load( "traceback": errors, } # 记录注册失败的插件名称,以便后续重载插件 + if path in star_map: + logger.info("失败插件依旧在插件列表中,正在清理...") + metadata = star_map.pop(path) + if metadata in star_registry: + star_registry.remove(metadata) # 清除 pip.main 导致的多余的 logging handlers for handler in logging.root.handlers[:]: diff --git a/dashboard/src/views/ExtensionPage.vue b/dashboard/src/views/ExtensionPage.vue index 9c7245648..74a5558fb 100644 --- a/dashboard/src/views/ExtensionPage.vue +++ b/dashboard/src/views/ExtensionPage.vue @@ -747,12 +747,13 @@ const showPluginInfo = (plugin) => { const reloadPlugin = async (plugin_name) => { try { const res = await axios.post("/api/plugin/reload", { name: plugin_name }); + await getExtensions(); if (res.data.status === "error") { toast(res.data.message, "error"); return; } toast(tm("messages.reloadSuccess"), "success"); - getExtensions(); + //getExtensions(); } catch (err) { toast(err, "error"); }