Skip to content

[Bug]重载失败插件时无法正确获取插件的最新状态 #5461

@Waterwzy

Description

@Waterwzy

What happened / 发生了什么

当载入插件出现错误的时候(例如RuntimeError),如果修复错误后点击“尝试一键重载插件”,修改后的插件没有被正确加载,重载仍然失败。

Reproduce / 如何复现?

例如,构建一个插件的初始化方法:

    def __init__(self, context: Context):
        super().__init__(context)
        raise RuntimeError("这是一个人为错误")

载入插件报错:

Image 但是如果把raise error去掉保存代码,点击“尝试一键重载所有插件”,这个报错信息没有改变,说明新的插件信息没有正确被获取

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

4.18.2 手动部署

OS

Windows

Logs / 报错日志

[2026-02-25 20:59:08.170] [Core] [INFO] [star.star_manager:524]: 正在载入插件 astrbot_plugin_import_test ...
[2026-02-25 20:59:08.171] [Core] [DBUG] [star.star_manager:685]: 插件 data.plugins.astrbot_plugin_import_test.main 未通过装饰器注册。尝试通过旧版本方式载入。
[2026-02-25 20:59:08.171] [Core] [ERRO] [v4.18.2] [star.star_manager:803]: ----- 插件 astrbot_plugin_import_test 载入失败 -----
[2026-02-25 20:59:08.173] [Core] [ERRO] [v4.18.2] [star.star_manager:806]: | Traceback (most recent call last):
[2026-02-25 20:59:08.174] [Core] [ERRO] [v4.18.2] [star.star_manager:806]: | File "C:\Users\53219\Desktop\bottest\AstrBot-master\astrbot\core\star\star_manager.py", line 703, in load
[2026-02-25 20:59:08.174] [Core] [ERRO] [v4.18.2] [star.star_manager:806]: | obj = getattr(module, classes[0])(
[2026-02-25 20:59:08.175] [Core] [ERRO] [v4.18.2] [star.star_manager:806]: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2026-02-25 20:59:08.175] [Core] [ERRO] [v4.18.2] [star.star_manager:806]: | File "C:\Users\53219\Desktop\bottest\AstrBot-master\data\plugins\astrbot_plugin_import_test\main.py", line 9, in init
[2026-02-25 20:59:08.176] [Core] [ERRO] [v4.18.2] [star.star_manager:806]: | #raise RuntimeError("这是一个人为错误")
[2026-02-25 20:59:08.176] [Core] [ERRO] [v4.18.2] [star.star_manager:806]: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2026-02-25 20:59:08.177] [Core] [ERRO] [v4.18.2] [star.star_manager:806]: | RuntimeError: 这是一个人为错误
[2026-02-25 20:59:08.177] [Core] [ERRO] [v4.18.2] [star.star_manager:806]: |
[2026-02-25 20:59:08.178] [Core] [ERRO] [v4.18.2] [star.star_manager:807]: ----------------------------------

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coreThe bug / feature is about astrbot's core, backendbugSomething isn't workingfeature:pluginThe bug / feature is about AstrBot plugin system.plugin-cate:opsSystem operations, monitoring, administration, and runtime status.(only startswith [Plugin])priority: p0will fix asap

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions