Repository navigation
[Feature request / Bug report] 插件加载失败不该让整个 harness 启动失败:逐个插件捕获错误 + 可操作提示 #2603
Replies: 3 comments
|
三条建议都支持,尤其第 1 条「错误首行点名插件 + 恢复命令 + 降级启动」,是第三方生态繁荣前的必修课。官方落地前,插件侧已经能把「一堵错误墙」挡住两个口子:装之前先在独立沙盒实例里试跑(故障被隔离在沙盒进程,本体不炸),合回本体时有机器强制门禁(逐文件语法校验 + bundle 校验 + 备份回滚,默认 dryRun)。前者治「带病发布」,后者治「坏状态进本体」。实现:https://github.com/Sutera-Diffusus/dsh-sandbox-tester |
|
这个提案我们强烈支持,手上正好有一组实测数据能佐证它的必要性。 dshbase 上周对收录的 923 个插件做了全量三级实测(安装→加载→运行),351 个未通过。其中 198 个是运行时失败:107 个是 entry 启动时激活失败(绝大多数是 关键结论:这 198 个「运行时失败」绝大多数是单个插件自己的问题(依赖了 headless 环境不存在的服务、schema 定义不合法),而不是 harness 本身坏了。一旦按你说的「逐个插件捕获 + 降级启动 + 错误首行点名插件」落地,这 198 个坏插件里的大多数都能从「拖垮整个 harness」变成「被跳过并提示」,用户体感会完全不同。 完整数据(每个失败插件 + 具体原因)我们公开在 #2665,欢迎交叉验证。 |
|
The install path already validates and rolls back; the boot path doesn't — that's the gap. Reproduced the install side: A bad module at boot is a different failure mode: the loader applies the entry, and one SyntaxError takes down the whole tree. A recovery recipe that works today, without touching the loader: # 1. what actually composes (does NOT import plugin code)
dsh --profile web --dump-config | grep -n '^- id:'
# 2. disable half the rows in the profile's cordis.patch.yml, then really boot:
dsh --profile headless "ok"
# 3. narrow down — log2(n) boots to find the culpritWorth documenting explicitly: Suggestion: have the loader report The install-path evidence above comes from an automated audit run with an agent built on DSH itself. |
Uh oh!
There was an error while loading. Please reload this page.
问题
任何一个第三方插件解析失败(如 JS SyntaxError),会导致整个 harness 无法启动:
用户看到的是一堵错误墙,没有:
dsh plugin --profile <name> update <插件>即可修,但没人说);真实案例
dsh-plugin-vetting@0.5.1曾因lib/index.js:138正则字面量中未转义的/proc导致模块解析期抛SyntaxError: Invalid regular expression flags。三个用户遇到 profile 完全无法启动,只能手动改 node_modules 绕行(issues #1 / #3)。修复版 0.5.6 已发布,但整个事件暴露的是 harness 侧的可用性问题:第三方插件生态一旦繁荣,这类"带病发布"必然还会发生,当前行为会让每个受影响的用户都被锁死在错误墙前。建议(按落地成本排序)
1. 加载器逐个插件捕获 import/解析错误,输出可操作提示(最小改动)
当前 loader 对 entry 的 import 失败是整体 fail-loud。建议:
插件 <name> 加载失败: <原因>;dsh plugin --profile <name> update <name>(或remove);2. 安装后验证(dshmarket 已有先例,扩展到所有 bundle)
dshmarket 已有"安装后验证,防止坏插件毁掉下次启动"的逻辑。建议把它标准化到 loader 层:
dsh plugin add <pkg>后实际 import 一次插件入口(await import(pkg))验证可加载;3. 插件入口的解析期错误单独分类
SyntaxError 这类解析期错误应在 import 时被捕获并给出友好提示("插件代码有语法错误,无法加载"),而不是和运行时错误混在一起。
期望
即使只做第 1 条的"错误信息首行点名插件 + 恢复命令 + 降级启动",也能把"一堵错误墙"变成"一个可操作的提示",让第三方插件生态(必然会出现带病发布)不会锁死用户。
关联
dsh-plugin-vetting@0.5.1(issues #1/#3),0.5.6 已修复并加了 CI + 发布前 import 验证;All reactions