Repository navigation
fix(bridge): keep the extension connected on dsh 0.2.1 (Peer is mandatory) - #130
Open
under-the-ocean wants to merge 1 commit into
Open
under-the-ocean wants to merge 1 commit into
under-the-ocean wants to merge 1 commit into
Conversation
dsh 0.2.1-rc.2 made PeerScope mandatory on both TypertGateway.invoke and
wireStream.open: open() runs assertPeerLive(peer) and reads peer.signal, so a
call without a peer rejects with "TypeError: Cannot read properties of
undefined (reading 'signal')".
The bridge passed undefined for that slot, so on 0.2.1 the extension received
hello.ok and then an immediate { t: 'error', code: 'stream-failed' } followed by
WS 1011 and an endless reconnect loop: the side panel stayed on "dsh is not
connected".
Resolve the Peer once from the Connection service (browserPeer, else
createPeer({ principal: { kind: 'owner' } })) and forward it through invoke,
workspace/follow, session/follow and the $events stream. Runtimes that expose
neither keep the previous peerless call, so dsh 0.2.0 is unaffected.
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On dsh 0.2.1-rc.2 the Chrome/Edge extension can never stay connected: the panel loops on “dsh is not connected (check the bridge address and token in Settings)”, and the host log shows nothing.
Captured on the extension service worker (CDP, Edge 157) against a real
dsh webhost:Root cause
dsh 0.2.1 made
PeerScopemandatory on both Gateway entry points the bridge uses:TypertGatewayWireStream.open(endpoint, payload, uplink, peer, signal)— 0.2.1 runsassertPeerLive(peer)and readspeer.signal; the typings now say “@PARAM peer — Peer the stream speaks for; required, never defaulted.”InvokeRemoteRequest.peer— likewise required (“every carrier and in-process caller names it explicitly”).remote-host-api.tspassedundefinedfor that slot, which dsh 0.2.0 tolerated. On 0.2.1 the$eventsstream therefore fails right afterhello.ok, so the extension never reaches a usable state — and every RPC would fail for the same reason.Fix
Resolve the Peer once from the injected Connection service and forward it through every Gateway call:
resolvePeer(connection):connection.browserPeer(0.2.1 admits browser traffic through an owner Peer) → falls back toconnection.createPeer({ principal: { kind: 'owner' } })invoke,workspace/follow,session/follow(including the one-shot snapshot helper) and$eventspeer === undefinedstill passes)Verification
DSH_HOME, own port) probed with the extension’s own wire protocol:hello → hello.ok, then a realsession.listRPC →{"t":"rpc.result","id":"probe-1","ok":true,...}, socket stays open (nostream-failed).browser_list_tabsreturns real tabs, i.e. extension ↔ bridge ↔ dsh fully connected.tests/remote-host-api.spec.ts: 22 passed (3 new tests: peer forwarded frombrowserPeer; owner Peer minted viacreatePeer; peerless fallback preserved).token.spec.tsasserts file mode0600, which Windows cannot represent.Note for maintainers
peerDependenciesstill pins the dsh packages to0.2.0-rc.2, so running this plugin on 0.2.1 currently needsdsh plugin --profile web allow-version @yuxianglin/dsh-bridge-browser@0.0.7 --dsh-version 0.2.1-rc.2 --accept-risk.I left that declaration alone: widening it is a support-policy call (semver ranges need an explicit prerelease tuple to admit
0.2.1-rc.x), and I would rather do it in a follow-up once you decide the supported window. Happy to add it here if you prefer a single patch.CN 摘要:dsh 0.2.1 起
PeerScope在invoke/wireStream.open上变成必填(内部assertPeerLive(peer)会读peer.signal),插件仍按 0.2.0 传undefined,于是hello.ok后立刻stream-failed+ WS 1011,扩展无限重连。本 PR 从 Connection 服务解析 Peer(browserPeer,回退createPeer({principal:{kind:'owner'}}))并贯穿所有网关调用;无 peer 来源的运行时保持原行为,0.2.0 不受影响。已在隔离 0.2.1 宿主用扩展协议验证hello.ok+ 真实 RPC 成功,新增 3 个回归测试。