Missing WebSocket / Subscription Support
Description
The current implementation lacks WebSocket support for real-time subscriptions, which is a core feature of tRPC v10. While the subscription procedure type exists, it is not implemented. This prevents server-sent events or WebSocket-based real-time data streaming.
Current State
// In procedure.ts
subscription<TOutput>(
resolver: (opts: { ctx: any; input: any }) => TOutput | Promise<TOutput>
): Procedure<...>
Issues:
- No WebSocket server implementation
- No subscription handler in
dispatch.ts
- No client-side subscription link
- No observable/async iterator support
- No connection lifecycle management
Expected Implementation
Server-side:
- Add WebSocket adapter (
packages/server/src/adapters/ws.ts)
- Update dispatch to handle subscriptions (
executeSubscription)
- Add observable utilities (
packages/server/src/observable.ts)
Client-side:
- Add WebSocket link (
packages/client/src/links/ws.ts)
- Update proxy to handle subscriptions
- Add subscription types (
packages/client/src/types.ts)
Impact
High priority — blocks:
- Real-time features (live updates, notifications, chat)
- Server-sent events
- Streaming data (logs, metrics, progress)
- Any push-based updates
Affected Files
Server:
adapters/ws.ts (new)
observable.ts (new)
dispatch.ts (modify)
procedure.ts (modify)
types.ts (add Observable types)
Client:
links/ws.ts (new)
observable.ts (new)
proxy.ts (modify for subscriptions)
types.ts (add Observable types)
Example:
example/src/server.ts (WebSocket server)
example/src/client.ts (subscription demo)
References
Missing WebSocket / Subscription Support
Description
The current implementation lacks WebSocket support for real-time subscriptions, which is a core feature of tRPC v10. While the
subscriptionprocedure type exists, it is not implemented. This prevents server-sent events or WebSocket-based real-time data streaming.Current State
Issues:
dispatch.tsExpected Implementation
Server-side:
packages/server/src/adapters/ws.ts)executeSubscription)packages/server/src/observable.ts)Client-side:
packages/client/src/links/ws.ts)packages/client/src/types.ts)Impact
High priority — blocks:
Affected Files
Server:
adapters/ws.ts(new)observable.ts(new)dispatch.ts(modify)procedure.ts(modify)types.ts(add Observable types)Client:
links/ws.ts(new)observable.ts(new)proxy.ts(modify for subscriptions)types.ts(add Observable types)Example:
example/src/server.ts(WebSocket server)example/src/client.ts(subscription demo)References