Repository navigation
fix: pass the connection's owner Peer to every Host stream and RPC (dsh 0.2.1) - #128
yao-lin-lain wants to merge 1 commit into
Conversation
|
感谢这个修复 —— 这个 bug 确实存在:握手成功后立刻收到 不过同一处修复在 #121 里已有等价改动( 这个分支还差一处: 如果急需这个能力,可以先使用 fork 版本:https://github.com/graydovee/dsh-browser(v0.1.7 已发布, |
|
Thanks for reviewing — you were right, the unary path was missing. I've reworked the branch into a single commit (1 file, +17/−6). It now reuses Verified with a script driving the bridge directly, since the side panel's connection state can be misleading: Host→extension still works ( Re #121: |
525060f to
8363102
Compare
…sh 0.2.1)
dsh 0.2.1 requires a peer scope on every Remote call and reads `signal`,
`interactions` and `principal.kind` off it. The bridge still called the 0.2.0
way, so `hello.ok` was immediately followed by `stream-failed` / WS 1011 — and
even once the event stream connected, the extension→host unary calls
(session.create / session.history / session.models) kept failing with the same
"Cannot read properties of undefined (reading 'signal')".
Use the Peer the Connection service already publishes for authenticated browser
connections (`connection.browserPeer`: principal owner, interactions answer)
instead of creating another one, and thread it through:
- openWireStream(): peer instead of `undefined` (the 3-argument 0.2.0 shape
still takes the old path)
- createSharedFetchHandler('/api').fetch(request, peer)
- the four gateway.invoke({…}) call sites
Verified over the bridge: session.models and workspace.list now return ok:true,
and the host→extension tools keep working.
8363102 to
8d64283
Compare
Summary
Fixes bridge-browser on dsh 0.2.1 by passing the peer the Gateway expects to every Host call: the event stream, the
/apifetch handler, and the fourgateway.invokecall sites. Net change is 17 added lines in one file; nothing on the wire or in the extension changes.Motivation
Since 0.2.1 the Gateway expects a peer scope on every Remote call and reads
signal,interactionsandprincipal.kindoff it. The bridge still calls the 0.2.0 way, so the handshake succeeds and then immediately dies:It isn't a single spot either.
$events, the/apifetch and the extension→host unary calls (session.create,session.history,session.models) each fail on their own path, so fixing one doesn't reveal the others.Changes
The peer is
connection.browserPeer— the owner Peer the Connection service already publishes for authenticated browser connections (principalowner, interactionsanswer). So there's no new Peer to create, and its lifetime stays with the connection service:openWireStream()takes an optional peer and passes it instead ofundefined; the three-argument 0.2.0 shape still takes the old pathRemoteHostApiandEventGenerationhold that same instance —$eventsis opened by the latter and answered by the former, and a mismatched peer is what producesRemote event result belongs to another PeercreateSharedFetchHandler('/api').fetch(request, peer)gets its second argumentgateway.invoke({…})call sites passpeerHostConnectionLike,wireStream.open,invoke) accept it; all of them takeunknown, so no new interface is introducedTesting
Linux (WSL2), dsh 0.2.1-rc.2, Edge, extension loaded unpacked. I drove the bridge with a script rather than the side panel, so the panel's connection state couldn't mislead me:
The other direction (host → extension) still works:
browser_list_tabs,browser_open_tab,browser_get_text,browser_close_tab. Worth saying for whoever tests next: exercising the tools alone is not enough — that direction never goes throughinvoke.Impact
Only the bridge plugin. The extension, its tools and the message shapes are untouched. Requires dsh ≥ 0.2.1; 0.2.0 keeps the old call path. Platform independent.
Checklist
pnpm run build/bash -n scripts/install.sh) — not run. The repo's install script re-pins my local dsh dependency versions, so I verified against a locally patched build instead of runningpnpm install/buildOne thing up front: this duplicates
fb4d873efrom #121. Mine is one file and one commit, so it can land whenever; if #121 gets there first, just close this one.