Skip to content

Commit 9a75216

Browse files
committed
chore: fix lint issues
1 parent 051fdd3 commit 9a75216

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

packages/loro-websocket/src/client/index.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class LoroWebsocketClient {
148148

149149
// Start initial connection
150150
this.connectedPromise = this.createConnectedPromise();
151-
this.connect();
151+
void this.connect();
152152
}
153153

154154
private createConnectedPromise() {
@@ -192,7 +192,8 @@ export class LoroWebsocketClient {
192192
private setStatus(s: ClientStatusValue) {
193193
if (this.status === s) return;
194194
this.status = s;
195-
for (const cb of [...this.statusListeners]) {
195+
const listeners = Array.from(this.statusListeners);
196+
for (const cb of listeners) {
196197
try {
197198
cb(s);
198199
} catch {}
@@ -237,9 +238,15 @@ export class LoroWebsocketClient {
237238
}
238239

239240
private attachSocketListeners(ws: WebSocket): void {
240-
const open = () => this.onSocketOpen(ws);
241-
const error = (event: Event) => this.onSocketError(ws, event);
242-
const close = () => this.onSocketClose(ws);
241+
const open = () => {
242+
this.onSocketOpen(ws);
243+
};
244+
const error = (event: Event) => {
245+
this.onSocketError(ws, event);
246+
};
247+
const close = () => {
248+
this.onSocketClose(ws);
249+
};
243250
const message = (event: MessageEvent<string | ArrayBuffer>) => {
244251
void this.onSocketMessage(ws, event);
245252
};
@@ -383,13 +390,17 @@ export class LoroWebsocketClient {
383390
for (const [id, adaptor] of this.roomAdaptors) {
384391
const roomId = this.roomIds.get(id);
385392
if (!roomId) continue;
393+
const active = this.activeRooms.get(id);
394+
if (!active) continue;
386395
// Prepare a lightweight pending entry so JoinError handling can retry version formats
387-
const roomPromise = Promise.resolve(this.activeRooms.get(id)?.room!);
396+
const roomPromise = Promise.resolve(active.room);
388397
const pending: PendingRoom = {
389398
room: roomPromise,
390399
resolve: (res: JoinResponseOk) => {
391400
// On successful rejoin, let adaptor reconcile to server
392-
adaptor.handleJoinOk(res).catch(e => console.error(e));
401+
adaptor.handleJoinOk(res).catch(e => {
402+
console.error(e);
403+
});
393404
// Clean up pending entry for this id
394405
this.pendingRooms.delete(id);
395406
},
@@ -1043,7 +1054,8 @@ export class LoroWebsocketClient {
10431054
const rtt = Date.now() - this.awaitingPongSince;
10441055
if (rtt >= 0 && isFinite(rtt)) {
10451056
this.lastLatencyMs = rtt;
1046-
for (const cb of [...this.latencyListeners]) {
1057+
const listeners = Array.from(this.latencyListeners);
1058+
for (const cb of listeners) {
10471059
try {
10481060
cb(rtt);
10491061
} catch {}

packages/loro-websocket/src/server/simple-server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ export class SimpleServer {
160160
.catch(() => {})
161161
.finally(() => {
162162
try {
163-
wss.close(() => resolve());
163+
wss.close(() => {
164+
resolve();
165+
});
164166
} catch {
165167
resolve();
166168
}

0 commit comments

Comments
 (0)