chore: bump socket.io-client to 4.5.4

This commit is contained in:
dwelle
2022-12-31 19:28:28 +01:00
parent c8370b394c
commit 480db3f5b6
6 changed files with 74 additions and 167 deletions

View File

@@ -414,7 +414,27 @@ class Collab extends PureComponent<Props, CollabState> {
roomKey,
);
this.portal.socket.once("connect_error", fallbackInitializationHandler);
this.portal.socket.on("disconnect", (reason) => {
// reason `io server disconnect` probably means CORS issue
console.warn(
`${
this.portal.socketInitialized ? "initialized" : "uninitialized"
} socket disconnected from server: ${reason}`,
);
this.setState({
errorMessage: this.portal.socketInitialized
? t("errors.socketDisconnected")
: t("errors.socketConnectionError"),
});
fallbackInitializationHandler();
});
this.portal.socket.once("connect_error", (err: any) => {
this.setState({
errorMessage: t("errors.socketConnectionError"),
});
fallbackInitializationHandler();
});
} catch (error: any) {
console.error(error);
this.setState({ errorMessage: error.message });

View File

@@ -19,10 +19,11 @@ import { newElementWith } from "../../element/mutateElement";
import { BroadcastedExcalidrawElement } from "./reconciliation";
import { encryptData } from "../../data/encryption";
import { PRECEDING_ELEMENT_KEY } from "../../constants";
import { Socket } from "socket.io-client";
class Portal {
collab: TCollabClass;
socket: SocketIOClient.Socket | null = null;
socket: Socket | null = null;
socketInitialized: boolean = false; // we don't want the socket to emit any updates until it is fully initialized
roomId: string | null = null;
roomKey: string | null = null;
@@ -32,7 +33,7 @@ class Portal {
this.collab = collab;
}
open(socket: SocketIOClient.Socket, id: string, key: string) {
open(socket: Socket, id: string, key: string) {
this.socket = socket;
this.roomId = id;
this.roomKey = key;