Skip to content

Commit 5edcc4d

Browse files
authored
fix: renderRealtimeClients() usage with client navigation (#611)
## Problem For each realtime channel, we currently store the relevant url for each connected client, and use this when rendering clients on demand using `renderRealtimeClients()`. However, we weren't accounting for changes to the url done as a result of client navigation. ## Solution We already use each url we get for a client when client actions and navigations happen to determine how the client should be updated. We just need to store this latest url as the new url for usage with `renderRealtimeClient()`.
1 parent 3bfc7ff commit 5edcc4d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sdk/src/runtime/lib/realtime/durableObject.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class RealtimeDurableObject extends DurableObject {
7474

7575
async webSocketMessage(ws: WebSocket, data: ArrayBuffer) {
7676
const clientId = ws.deserializeAttachment() as string;
77-
const clientInfo = await this.getClientInfo(clientId);
77+
let clientInfo = await this.getClientInfo(clientId);
7878

7979
const message = new Uint8Array(data);
8080
const messageType = message[0];
@@ -84,6 +84,13 @@ export class RealtimeDurableObject extends DurableObject {
8484
const jsonData = decoder.decode(message.slice(1));
8585
const { id, args, requestId, clientUrl } = JSON.parse(jsonData);
8686

87+
clientInfo = {
88+
...clientInfo,
89+
url: clientUrl,
90+
};
91+
92+
await this.storeClientInfo(clientInfo);
93+
8794
try {
8895
await this.handleAction(ws, id, args, clientInfo, requestId, clientUrl);
8996
} catch (error) {

0 commit comments

Comments
 (0)