T
tRPC

How does trpc subscription actively close/disconnect in the server?

How does trpc subscription actively close/disconnect in the server?

Qqingmu6/4/2023
How do I actively disconnect my subscription?
AEAhmed Eid6/4/2023
I believe you have to just unmount the component that uses useSubscription but it's a good question if you're not using react.
AEAhmed Eid6/4/2023
there seem to be an unsubscribe method on the subscription returned value.
Qqingmu6/5/2023
The problem arises on the back end. I don't seem to be able to actively cancel useSubscription in react either?
AEAhmed Eid6/5/2023
I'm not sure, but in my experience I found it closing the connection whenever the component unmounts.
AKAlex / KATT 🐱6/5/2023
you can use broadcastReconnectNotification() to tell all clients to disconnect and reconnect gracefully example https://github.com/trpc/examples-next-prisma-websockets-starter/blob/ba462445a1fea43161a40b24e9b54ff71502fef7/src/server/prodServer.ts#L32-L35 you can use ws to loop through connected clients and force shut them
Qqingmu6/7/2023
I am implementing the SSE based subscription feature and I am currently finding issues with not receiving events from client closures in NextJS.

Looking for more? Join the community!

T
tRPC

How does trpc subscription actively close/disconnect in the server?

Join Server
Recommended Posts
child router questionlet's say we have a monorepo, one server, two client apps (cat and dog). we make one appRouter, likHow to force SSL on projects using tRPC?Hello everyone, I'm working on a project that uses create-t3-app as boilerplate. My project is hosAWS Lambda / How to set Cookies inside ProceduresHow can I set and remove cookies similar to ctx.res.cookie(..) with Express when using the aws lambdMassive Type Errors on tRPC 10 Legacy Router against MergeRouterWe're trying to upgrade to tRPC 10 but I am running into a massive type clash when trying to merge rIs it possible to create 2 routers inside a single file?I am having an issue in which it is impossible to me to use a class instance within 2 routers. I triUse onError to change an application error into a TRPCError?I want to use the onError handler to change any instance of a custom application error into a TRPCErIncreasing Body 1mb limitHey, Im trying to build an application that allows sending of base64 encoded files to my next.js serNitro and tRPC in vercel-edgeHey there! I hope this is the right place to ask for help. I am trying to deploy an application witHow to retrieve and receive Bigint data to/from TRPC procedureNode: `v16.15.1` I'm trying to return an object which contains an `amount` property from one of my React Router Loaders + tRPC?In Vite project: would it make sense to use React Router loaders with tRPC? I like more the concept TypeError: Cannot read properties of null (reading 'useContext') when using useMutation with TRPC inI'm encountering an error in my Next.js application when trying to use the useMutation hook with TRPInitial websockets getToken() returns null: next-auth + websockets :)Hello! So the way I am trying to authenticate websockets is like this: ``` import { getToken } froCan I get the original type name, instead of the shape, with query?I'm not sure how to explain it, so, here's a screen shot:TRPCClientError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON ErrorHello folks, I'm getting an issue with my integration, I'm a newbie in tRPC and I can't work well mytrpc corsmy sveltekit app is running on https://example.com with tRPC and it's making requests to http://127.T3 app tRPC external callsCurrently i'm just making Post request and formatting my payload to ```{ "0": { "json":Next-auth session not being fetched in tRPC contextNext-auth session not being fetched in tRPC contextuseMutation not handeling arguments correctly.Hello, I have a mutation setup on the server with the input being an object containing the fields emUpdate Clerk Organization from TRPC Router (T3 Stack)Hello, if anyone got an idea on how to handle this I would highly appreciate it. I have some organiHow to not send request in specific condition in useQuery()```js const { data: artists, isLoading } = api.findArtist.useQuery({ name: search, }); ```