How to end subscription obeservables properly from server? #4060
Replies: 3 comments 9 replies
-
|
Perhaps change the title? If I understand your question correct it's about closing the subscription and not the wsLink? The wsLink will be active throughout the lifetime of the TRPCProxyClient. Unfortunately I'm not sure why your code isn't working. Looking at it I would assume it should work. Hopefully someone else can contribute! |
Beta Was this translation helpful? Give feedback.
-
|
I've asked about ending subscriptions from server earlier: |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is my server code and at some point of time I will call
emit.complete()my client code. bascially setting up some dumb listeners
But I get

TRPCClientError: Operation ended prematurelyby simplyemit.on("complete")So my onError listeners are triggered and the page state are updated to an error state which is undesirable. Have I done sth wrong? Isn't it normal to complete the observable on server?
I also checked the code and found
isDoneis related to the error. But I don't think it's possible to be changed on the server becauseisDoneis only manipulated from the error callback.trpc/packages/client/src/links/wsLink.ts
Lines 330 to 334 in 949f42b
Beta Was this translation helpful? Give feedback.
All reactions