Skip to content
Source
Sign inSign up
pingdotgg/t3code

Preserve live stream subscriptions across explicit reconnects #1972

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/1972/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 114 additions and 1 deletion.

x
0 of 2 viewed, 2 left
109 additions and 0 deletionsapps/web/src/rpc/wsTransport.test.tsModified
View file
@@ -639,6 +639,115 @@
await transport.dispose();
});
​
+ it("re-subscribes live stream listeners after an explicit transport reconnect", async () => {
+ const transport = createTransport("ws://localhost:3020");
+ const listener = vi.fn();
+ const onResubscribe = vi.fn();
+​
+ const unsubscribe = transport.subscribe(
+ (client) => client[WS_METHODS.subscribeServerLifecycle]({}),
+ listener,
+ { onResubscribe },
+ );
+​
+ await waitFor(() => {
+ expect(sockets).toHaveLength(1);
+ });
+​
+ const firstSocket = getSocket();
+ firstSocket.open();
+​
+ await waitFor(() => {
+ expect(firstSocket.sent).toHaveLength(1);
+ });
+​
+ const firstRequest = JSON.parse(firstSocket.sent[0] ?? "{}") as { id: string };
+ const firstEvent = {
+ version: 1,
+ sequence: 1,