You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`DevframeRpcClient` has no `close()`/`dispose()` of any kind — a connection
lives until the process ends, with no way for a caller to tear it down. The
server transport already has the symmetric piece: `WsRpcTransport.close()`
(attachWsRpcTransport) detaches upgrade routing, force-closes every connected
peer, and closes any server it created itself. The client side has never had
an equivalent.
This bites any caller that races a connection attempt against its own
deadline (`Promise.race([connectDevframe(...), timeout])`) — the deadline
can't cancel the loser, so a slow-to-resolve attempt becomes a fully
connected, unreferenced client with nothing able to close it.
## Changes
- `createWsRpcChannel` (rpc/transports/ws-client.ts) returns `close()`,
closing the underlying `WebSocket`. Widens its return type to
`ChannelOptions & { close: () => void }`, since birpc's own `ChannelOptions`
has no teardown of its own.
- `createWsRpcClientMode` hoists its channel to a local so it can close it,
and exposes `close()` on `DevframeRpcClientMode`.
- `createStaticRpcClientMode` gets a no-op `close()` — a static backend has
no live socket, every call is a local fetch — so the two modes stay
union-compatible.
- `DevframeRpcClient.close()` delegates to the mode. No behavior change for
anyone not calling it.
## Tests
- `ws-client.test.ts` (new): `close()` closes the underlying `WebSocket`.
- `rpc-ws-status.test.ts`: `createWsRpcClientMode`'s `close()` closes its
socket.
- `rpc.test.ts`: `getDevframeRpcClient`'s `close()` closes the socket on a
`websocket` backend, and is a no-op (not a throw) on a `static` one.
- `rpc-auth-gate.test.ts`: updated its hand-typed `DevframeRpcClientMode` mock
for the new required field.
`pnpm --filter devframe exec tsc --noEmit` clean. `pnpm exec vitest run
--project devframe` — 51 files, 463 tests (was 459), all green. Also ran
`--project @devframes/hub --project @devframes/hub-ui` (129 tests) and
`tsc --noEmit` across `@devframes/hub`, `@devframes/hub-ui`, `@devframes/nuxt`
— the packages consuming `DevframeRpcClient` — clean. `eslint` clean on every
touched file.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
0 commit comments