Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/loro-websocket/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class LoroWebsocketClient {
}> = [];

constructor(
private ops: { url: string; pingIntervalMs?: number; disablePing?: boolean }
private ops: { url: string; pingIntervalMs?: number; disablePing?: boolean, onWsClose?: () => void }
) {
this.connectedPromise = new Promise<void>((resolve, reject) => {
this.ws = new WebSocket(this.ops.url);
Expand Down Expand Up @@ -100,6 +100,7 @@ export class LoroWebsocketClient {
// Clear timers and pending waiters on close
this.ws.addEventListener('close', () => {
this.clearPingTimer();
this.ops.onWsClose?.();
this.rejectAllPingWaiters(new Error("WebSocket closed"));
});
}
Expand Down