Skip to content

refactor!: transport-neutral RPC sessions and connection meta - #193

Merged
antfu merged 1 commit into
mainfrom
refactor/transport-neutral-rpc-sessions
Aug 13, 2026
Merged

refactor!: transport-neutral RPC sessions and connection meta#193
antfu merged 1 commit into
mainfrom
refactor/transport-neutral-rpc-sessions

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Intent

Prepare the RPC layer for an SSE transport (SSE downstream + HTTP POST upstream, landing in a follow-up PR) by removing the WebSocket-specific assumptions from the session seam — with zero behavior change.

What changed

  • DevframeRpcConnection — a transport-neutral connection object (id, transport kind, connect-time request for token/origin reading, send/close), defined in the new rpc/transports/session module together with the session-meta minting so every transport shares one session id space. The crossws Peer remains reachable as the WS-specific escape hatch (connection.peer, meta.peer).
  • Lifecycle hooks take the neutral objectonPeerConnect / onPeerDisconnect (initiate, dev adapter, instance shell, rpc-core) and DevframeAuthHandler.onConnect now receive DevframeRpcConnection instead of Peer. The interactive-auth recipe already read only request.url / request.headers, so it works for any transport supplying the request.
  • ConnectionMeta widened ahead of SSEbackend gains 'sse' (primary-SSE deployments) and 'none' (RPC-less shells, e.g. MCP-only); new sse endpoint field (ConnectionMetaSse) mirroring the proxy-safe websocket shape and resolution rules. Nothing produces these values yet.
  • API snapshots regenerated (breaking change acknowledged via the tsnapi guard).

Breaking change

onPeerConnect / onPeerDisconnect callbacks and DevframeAuthHandler.onConnect receive a DevframeRpcConnection instead of a crossws Peer; use connection.peer for raw peer access.


Created with the help of an agent.

Introduce a transport-neutral `DevframeRpcConnection` (id, transport kind,
connect-time request, send/close, with the crossws `Peer` kept as a
WS-specific escape hatch) and route every connection lifecycle hook through
it — `onPeerConnect` / `onPeerDisconnect` options, `DevframeAuthHandler.onConnect`,
and the transport binding's `onConnected` / `onDisconnected` — instead of the
raw crossws `Peer`. Session meta minting moves to a shared
`rpc/transports/session` module so future transports share one id space.

Also widens `ConnectionMeta` ahead of the SSE transport: `backend` gains
'sse' / 'none', and an `sse` endpoint field (`ConnectionMetaSse`) mirrors the
proxy-safe `websocket` shape.

BREAKING CHANGE: `onPeerConnect` / `onPeerDisconnect` callbacks and
`DevframeAuthHandler.onConnect` now receive a `DevframeRpcConnection`
instead of a crossws `Peer`; reach the peer via `connection.peer`.
@netlify

netlify Bot commented Aug 13, 2026

Copy link
Copy Markdown

Deploy Preview for devfra failed.

Name Link
🔨 Latest commit 6611125
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a7d2bd19b691a00088141f6

@antfu
antfu merged commit 9361d30 into main Aug 13, 2026
8 of 12 checks passed
@antfu
antfu deleted the refactor/transport-neutral-rpc-sessions branch August 13, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants