refactor!: transport-neutral RPC sessions and connection meta - #193
Merged
Conversation
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`.
❌ Deploy Preview for devfra failed.
|
antfu
approved these changes
Aug 13, 2026
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.
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 newrpc/transports/sessionmodule together with the session-meta minting so every transport shares one session id space. The crosswsPeerremains reachable as the WS-specific escape hatch (connection.peer,meta.peer).onPeerConnect/onPeerDisconnect(initiate, dev adapter, instance shell, rpc-core) andDevframeAuthHandler.onConnectnow receiveDevframeRpcConnectioninstead ofPeer. The interactive-auth recipe already read onlyrequest.url/request.headers, so it works for any transport supplying the request.ConnectionMetawidened ahead of SSE —backendgains'sse'(primary-SSE deployments) and'none'(RPC-less shells, e.g. MCP-only); newsseendpoint field (ConnectionMetaSse) mirroring the proxy-safewebsocketshape and resolution rules. Nothing produces these values yet.Breaking change
onPeerConnect/onPeerDisconnectcallbacks andDevframeAuthHandler.onConnectreceive aDevframeRpcConnectioninstead of a crosswsPeer; useconnection.peerfor raw peer access.Created with the help of an agent.