fix(host): mount dedicated RPC channels via webServer for post-alpha.2 DSH masters - #177
fix(host): mount dedicated RPC channels via webServer for post-alpha.2 DSH masters#177CnsMaple wants to merge 1 commit into
Conversation
|
感谢提交修复和复现信息。我们核对了本地 alpha.2 源码及官方 npm 包,其中 Connection 的 排查中发现,渠道初始化失败发生在管理接口挂载之前,也会导致请求落入静态页面兜底并返回 405。我们已将管理接口提前挂载,并为全部 11 个渠道/连接器入口增加初始化状态和错误提示,修复已合入 main:2dd915d。2531 项测试及 alpha.2 官方组件的 HTTP 验证通过。 你报告的 13 个接口同时失联仍需要进一步定位。请补充 DSH 的安装来源、实际加载的 Connection 包版本,以及 目前先暂缓合并直接挂载 WebServer 的方案,待确认环境差异后再决定是否需要修改传输层。 |
…2 DSH masters Dropped webServer from client-connection top-level inject in unreleased DSH master (commit 2ef85b1e17 fix: windows build; the alpha.2 tag still injects it), so connection.rpc.handle() will throw cannot get property "webServer" without inject for every plugin caller once the next DSH release ships. dsh-im activates channels inside try/catch, so boot survives but channel transports are silently lost: browser RPC calls (e.g. /feishu/connection.status) fall through to the SPA handler and answer HTTP 405. Route all 13 mount sites through one shared installRpcChannel helper that resolves webServer via the inject-free ctx.get(), registers the prefix route with the same auth fence (connection.requestRejection) and client-request / server-response envelope semantics as the Connection plugin, and falls back to connection.rpc.handle when no webServer service exists (released DSH versions and programmatic test fakes). Add regression tests for the new mount path.
|
感谢核对,你们是对的——原描述版本归属有误:收缩 inject 的提交是 按请求补充环境信息与最新验证结果:
结论:两个原因相互独立且都成立——npm alpha.2 用户的 405 已由你们的顺序修复解决;而 master 环境下(以及 alpha.3/rc 等下一个发布版本起,届时所有 |
|
已确认 既然上游已用自有方案(且连同客户端协议与鉴权策略一起调整)解决,本 PR 撤回关闭,避免双轨维护。留档:dsh-pocket 侧同根因的 PR 见 shaobeichen/dsh-pocket#108(该仓库尚未跟进的话, 感谢快速响应和版本归属的纠正。 |
|
Superseded by 503a24a (fetch-route approach). Closing. |
|
补充一条实况更新:此前在 alpha.2 环境反馈"仍未修复",实为升级后 host 进程未换血——磁盘已装新版但运行中的 server 还持有旧挂载代码,浏览器新客户端打到旧进程上表现为 |
Problem
On a DSH built from
deepseek-harnessmaster, every dsh-im channel settings page shows transport errors such as:The plugin boots, but all dedicated RPC channels (
/feishu,/dingtalk,/qq,/wecom,/slack,/telegram,/whatsapp,/weixin,/office,/dsh-im, delivery and inbound-TTL channels) are silently missing; their requests fall through to the SPA handler and are answered405.Version attribution (corrected after @xmanrui's review): the underlying inject change landed in unreleased master only —
2ef85b1e17("fix: windows build", merged via the feat/electron chain). Thedsh-v0.1.3-alpha.1anddsh-v0.1.3-alpha.2tags and the published npm packages still injectwebServerin client-connection, soconnection.rpc.handle()works there (as the maintainer verified — an independent init-ordering bug, fixed in2dd915d, is what reproduces 405s on alpha.2). This PR is forward-compatibility for the next DSH release (alpha.3/rc will break everyrpc.handleplugin otherwise; dsh-pocket crashes the whole plugin tree on master withcannot get property "webServer" without inject).Root cause (master)
Master's client-connection plugin changed its top-level inject from
['webServer', 'credentials']to['credentials'](making Connection carrier-neutral).rpc.handle()still mounts its channel as awebServerprefix route by readingwebServeroff the Connection plugin's own fiber context — which can no longer resolve it — so from any plugin caller it throws:For dsh-im specifically,
activateChannels()isolates each channel with try/catch, so boot survives and the channels just vanish (dsh-im #177 context; identical mechanism as the dsh-pocket crash above).Fix
Route all 13 mount sites through one shared helper,
plugin-src/host/rpc-mount.mjs:webServerwith the inject-freectx.get('webServer')and register the prefix route directly, replicating the Connection plugin's own route semantics 1:1: the same auth fence (connection.requestRejection, 401/403 branches), the sameclient-request/server-responsewire envelope (404/415/400/gateway/bad-request/500 branches, buffered-body cap matching the Connection default). The third{ authority }option was never consumed by Connection and is only passed through on the fallback path.ctx.effect()and returns a disposer, preserving the previous lifetime semantics.webServerservice exists (released-host fixtures, programmatic test fakes) it falls back toconnection.rpc.handle()verbatim. On released DSH (alpha.2 and earlier)webServeris always provided by the web host, where the direct mount is behaviorally equivalent to whatrpc.handle()does internally.Validation
2dd915d(management-RPC ordering fix).test/rpc-mount.test.mjs(direct mount, auth fence, envelope branches, 500, legacy fallback, TypeError) — 6/6 pass.rpc-mount+test/channels/shared/startup.test.mjs(new upstream startup tests) +host.test.mjs+ update/delivery rpc — 80/80 pass.0600file-mode assertions, path-regex escaping, etc.).lib/index.jswith the repo's ownnode plugin-src/host/build.mjs.中文摘要:DSH **master(未发布,commit
2ef85b1e17)**将 client-connection 的 inject 从['webServer','credentials']收缩为['credentials'],connection.rpc.handle()内部解析webServer的路径从任何插件调用方必抛cannot get property "webServer" without inject;alpha.1/alpha.2 tag 与 npm 包仍注入 webServer、不受影响(维护者在 alpha.2 上验证到的是另一个初始化顺序问题,已由2dd915d修复)。本 PR 为下一个 DSH 发布版本提供前向兼容:13 处通道挂载改走共享installRpcChannel()——优先用免 inject 的ctx.get('webServer')直挂 prefix 路由,认证门与 RPC 信封语义逐分支对齐 Connection 原实现,线协议不变;无 webServer 服务时原样回退rpc.handle(兼容已发布版本与测试 mock)。已 rebase 至2dd915d,80/80 关键测试通过。