Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tRPC subscriptions (WebSockets) #19

Open
ben-xD opened this issue Jun 8, 2023 · 1 comment
Open

Support tRPC subscriptions (WebSockets) #19

ben-xD opened this issue Jun 8, 2023 · 1 comment

Comments

@ben-xD
Copy link

ben-xD commented Jun 8, 2023

Is your feature request related to a problem? Please describe.
This package doesn't support tRPC subscriptions (websockets), for example when the client looks like:

import { createTRPCProxyClient, createWSClient, wsLink } from '@trpc/client';
import type { AppRouter } from '../path/to/server/trpc';

// create persistent WebSocket connection
const wsClient = createWSClient({
  url: `ws://localhost:3001`,
});

const client = createTRPCProxyClient<AppRouter>({
  links: [
    wsLink({
      client: wsClient,
    }),
  ],
});

Unfortunately, the client/test will time out because the http request never gets upgraded to websocket.

Describe the solution you'd like
Handle the initial http request for upgrading from http to WebSocket. The request has headers:

headers@2x

Then, the package might also get another cool feature: to control when messages/event on the tRPC subscription (websocket) are sent to the client in the test.

@ben-xD ben-xD changed the title Support WebSockets Support tRPC subscriptions (WebSockets) Jun 8, 2023
@maloguertin
Copy link
Owner

Hi! This is something I'd like to support but I'm a little busy as of now. Would you be interested in making a PR?

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

No branches or pull requests

2 participants