bROMB
tRPC2y ago
bROM

Anyone has successfully setup a websockets subscription with an input ?

Hi guys, here is my environment:
* node v20.11.1
* yarn@4.1.0
* trpc 11.0.0-next-beta.294
* next 14.1.4


I am trying to setup a websockets subscription providing a number (or any other zod type) as input:
Code example:

server-side:
onUpdated: publicProcedure .input(z.number()) .subscription(({ input: { id } }) => { // TODO })

client-side:
api.myapi.onUpdated.useSubscription( 10, { onError(e) { console.log("not updated error => ", e); }, enabled: true, onData({ payload }) { // TODO ... }, }, );

The error I am getting is the following:

TRPCClientError: Unknown error at TRPCClientError.from (http://myurl:3000/_next/static/chunks/node_modules_7616f9._.js:776:20) at Object.next (http://myurl:3000/_next/static/chunks/node_modules_7616f9._.js:2304:223) at handleIncomingResponse (http://myurl:3000/_next/static/chunks/node_modules_7616f9._.js:2155:37) at WebSocket.<anonymous> (http://myurl:3000/_next/static/chunks/node_modules_7616f9._.js:2172:21)

It disappears if I remove the .input line.

Very hard to debug with the "Unknown error" message... Should I open a GitHub issue? Anyone faced this issue before?

Thanks 👍
Was this page helpful?