[Bug] 解析拦截器对只读 stack 赋值抛 TypeError,导致全部插件元信息报错(v0.1.7-alpha.2 / tsx 启动) #7533
Replies: 1 comment
|
Your diagnosis is correct, including the part you emphasized — The freeze comes from the hook chain, not from tsxSame Node, same specifier, one variable at a time; descriptor read off the real
The no-op loader is one line and does nothing but That also explains your environment's split: Two notes for anyone extending your repro:
On your suggested fixYour
Invariant worth writing next to the helper: the error that reaches Same bug, two other threadsThis is the third report of the identical mechanism: #7528 (Node 24.2.0, same tsx launch, with a library-level repro) and #7518 (macOS, |
Uh oh!
There was an error while loading. Please reload this page.
环境
dsh-v0.1.7-alpha.2(active.json指向的已安装版本)v22.20.0(DSH Desktop 内置 runtime)node --import tsx/esm apps/cli/src/bin.ts web --no-open --port 0现象
设置 → 插件页面里,几乎所有插件的元信息都报错:
不止 persona:
@deepseek-ai/dsh-skill、@deepseek-ai/dsh-tool-skill等大批包同样报错(用户反馈"这样的还很多")。根因
packages/boot/app-boot/src/profile-resolution/resolver.ts的throwWithImporter()在把解析路由到 declarer 后失败时改写诊断:--import tsx/esm)启动时,Node 抛出的ERR_PACKAGE_PATH_NOT_EXPORTED错误,其stack是 own data property 且writable: false:{"value":"Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: ...","writable":false,"enumerable":false,"configurable":true}error.stack = ...抛TypeError,而TypeError没有code。packages/boot/app-boot/src/package-meta.ts的missingResource()只识别error.code,认不出"这个包没有导出 locale",导致optionalResourcePath()不再返回undefined,readPluginMeta()把它当作元信息错误上报。./locale/en.json导出(仓库packages/下 578 个包目录里只有 6 个带locale/en.json),因此凡是缺 locale 的包全部中招。最小复现
去掉
--import tsx/esm后,同一错误的stack可写,问题不出现。建议修复
改写 stack 时不要假定可写:
throwWithImporter与throwWithoutCjsAnchor两处都应改用它。可选加固(防御任何包装层丢失
code):missingResource()除了error.code,也识别 Node 的is not defined by "exports"/Cannot find module文本,避免把"没有元数据"误报成错误。影响面
readPluginMeta的界面都受影响。修复后验证
readPluginMeta('@deepseek-ai/dsh-persona' | '@deepseek-ai/dsh-skill' | '@deepseek-ai/dsh-tool-skill')恢复正常元信息,error字段消失;code = ERR_PACKAGE_PATH_NOT_EXPORTED,不再被 TypeError 顶替;packages/boot/app-boot/tests/package-meta.spec.ts+tests/profile-resolution.spec.ts:303 passed / 1 skipped,0 failed。All reactions