Repository navigation
fix(bridge): speak for an in-process owner Peer on dsh 0.2.1 - #129
Open
flyingbug2 wants to merge 1 commit into
Open
flyingbug2 wants to merge 1 commit into
flyingbug2 wants to merge 1 commit into
Conversation
dsh 0.2.1 makes the Peer a hard requirement on every Gateway entry: `openWireStream`, `invoke`/`prepareInvocation` and `$events/result` all read `peer.signal`, so an undefined Peer throws `TypeError: Cannot read properties of undefined (reading 'signal')`. The bridge then closes the extension socket with 1011 right after `hello.ok` (the side panel reconnects forever), and every RPC — `workspace.create`, `session.create/list/page` — fails with `gateway/internal`. Mint one in-process owner Peer from the Host Connection service (`createPeer`, exposed from 0.2.1) and use it for wire streams, `invoke` requests and the `$events/result` fetch, so the answering Peer is the very object the stream was opened with. Kernels without `createPeer` (0.2.0 and earlier) keep the previous behaviour. Refs: browser-context V4 source kind is already handled on main.
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.
概述 / Summary
在 dsh 0.2.1 上给 Gateway 调用补上 in-process owner Peer:wire stream、
invoke、$events/result三处都带上同一个 Peer。动机 / Motivation
dsh 0.2.1 把 Peer 变成了每个 Gateway 入口的硬要求(0.2.0-rc.2 还没有这段代码):
openWireStream、prepareInvocation(invoke)、$events/result都会读peer.signal,而当前实现传undefined,于是:$events/session/follow一开就崩 →hello.ok之后立刻stream-failed+ws.close(1011)→ 侧栏无限重连;workspace.create、session.create/list/page)返回gateway/internal: Cannot read properties of undefined (reading 'signal')。实测报错(macOS,DSH NEXT 2.0.19-next / 内核 0.2.1-rc.2):
关键点:内核
connection服务自带createPeer({ principal, interactions })(注释即 "Create one in-process Peer owned by the Context that read this service"),进程内插件完全拿得到 owner Peer;且$events/result只要求同一个对象(client.peer !== peer判等),不需要与其它客户端共用。改动内容 / Changes
HostConnectionLike增加可选createPeer;createSharedFetchHandler().fetch增加可选peer。createBridgePeer(connection):createPeer({ principal: { kind: 'owner' }, interactions: 'answer' }),无createPeer的内核返回undefined(保持旧行为)。RemoteHostApi与EventGeneration各持一个peer,用于:openWireStream(...)五参载体的第 4 参(原来是undefined);gateway.invoke({...})请求体;$events/result的fetchHandler.fetch(request, peer)。createPeer时三处都带上该 Peer;无createPeer时保持undefined。测试 / Testing
macOS 14/15(arm64 + x64),DSH NEXT 2.0.19-next / 内核 0.2.1-rc.2:
pnpm run check:runtime✅pnpm run typecheck✅pnpm run test→ 394 passed ✅pnpm run build✅pnpm run test:smoke→Real DSH smoke passed: … V4 browser snapshots …✅~/.dsh/browser-sessions工作区,browser_snapshot/browser_get_text返回真实页面内容;宿主日志workspace.create failed归零。影响范围 / Impact
createPeer不存在时 Peer 保持undefined,与原行为逐字一致。Checklist
pnpm run build/bash -n scripts/install.sh等基础检查 / Passed basic checks