You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WebSocket transport does not allow healing connections #58
Is this intentional behaviour of the default websocket transport? If so, would a new ReconnectingWebsocket transport be acceptable or should this be left to userland? I'm not sure what your thoughts are about adding new transports to core.
Hmm, what are you imagining should happen to the session state on a reconnect? That is, what happens to stubs that were passed over the connection before the disconnect?
Possibilities include:
They are all just broken. Only the "main" stub is reconnected.
The client reconnects to the same server as before, where the session state still exists in memory, so that it can be resumed without losing anything.
On reconnect, the system automatically recreates all stubs by replaying the same calls that created them the first time.
I can't even tell when the WebSocket connection breaks. If I could, then I'd be able to call newWebSocketRpcSession again, get a new stub, and do my own replay.
I can listen to the WebSocket's close and error events, but that doesn't catch all cases where the (private) transport calls #recievedError.
I had to make my own transport for the server side (because of Bun), so it looks like I'll have to do that for the client too.
Edit: Looks like onRpcBroken can be used for this.
Yes, you can use onRpcBroken() to detect when the connection is lost. And from that you should be able to implement various approaches to handling this.
I could imagine having something more batteries-included, but it's not entirely clear what the behavior should be (see my previous comment).
Activity
kentonv commentedon Sep 27, 2025
Hmm, what are you imagining should happen to the session state on a reconnect? That is, what happens to stubs that were passed over the connection before the disconnect?
Possibilities include:
LoganDark commentedon Oct 17, 2025
I can't even tell when the WebSocket connection breaks. If I could, then I'd be able to call
newWebSocketRpcSessionagain, get a new stub, and do my own replay.I can listen to the WebSocket's
closeanderrorevents, but that doesn't catch all cases where the (private) transport calls#recievedError.I had to make my own transport for the server side (because of Bun), so it looks like I'll have to do that for the client too.
Edit: Looks like onRpcBroken can be used for this.
kentonv commentedon Oct 17, 2025
Yes, you can use
onRpcBroken()to detect when the connection is lost. And from that you should be able to implement various approaches to handling this.I could imagine having something more batteries-included, but it's not entirely clear what the behavior should be (see my previous comment).