diff --git a/app/features/chat/components/Chat.tsx b/app/features/chat/components/Chat.tsx index 779d5b776..702161b14 100644 --- a/app/features/chat/components/Chat.tsx +++ b/app/features/chat/components/Chat.tsx @@ -2,9 +2,9 @@ import { useRevalidator } from "@remix-run/react"; import clsx from "clsx"; import { sub } from "date-fns"; import { nanoid } from "nanoid"; +import { WebSocket } from "partysocket"; import * as React from "react"; import { useTranslation } from "react-i18next"; -import ReconnectingWebSocket from "reconnecting-websocket"; import type { Tables } from "~/db/tables"; import { useUser } from "~/features/auth/core/user"; import invariant from "~/utils/invariant"; @@ -332,7 +332,7 @@ export function useChat({ rooms[0]?.code, ); - const ws = React.useRef(); + const ws = React.useRef(); const lastSeenMessagesByRoomId = React.useRef>(new Map()); // same principal as here behind separating it into a ref: https://overreacted.io/making-setinterval-declarative-with-react-hooks/ @@ -350,7 +350,7 @@ export function useChat({ const url = `${import.meta.env.VITE_SKALOP_WS_URL}?${rooms .map((room) => `room=${room.code}`) .join("&")}`; - ws.current = new ReconnectingWebSocket(url, [], { + ws.current = new WebSocket(url, [], { maxReconnectionDelay: 10000 * 2, reconnectionDelayGrowFactor: 1.5, }); diff --git a/package-lock.json b/package-lock.json index 35cbccdf6..873166c9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,6 +45,7 @@ "nprogress": "^0.2.0", "openskill": "^4.1.0", "p-limit": "^6.2.0", + "partysocket": "^1.1.2", "react": "^18.3.1", "react-aria-components": "^1.7.0", "react-charts": "^3.0.0-beta.57", @@ -55,7 +56,6 @@ "react-i18next": "^15.4.1", "react-use": "^17.6.0", "react-use-draggable-scroll": "^0.4.7", - "reconnecting-websocket": "^4.4.0", "remix-auth": "^4.1.0", "remix-auth-oauth2": "^3.2.2", "remix-i18next": "^6.4.1", @@ -12688,6 +12688,27 @@ "node": ">= 0.8" } }, + "node_modules/partysocket": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/partysocket/-/partysocket-1.1.2.tgz", + "integrity": "sha512-vWyxg0dYJewBsT6BaYkq+DEavYw+N/8J0jUXYSuZRRJdnmMJY+rkCg19t/8c3pTSyg8FjJH8VzIaHBhFMQRDIw==", + "license": "ISC", + "dependencies": { + "event-target-shim": "^6.0.2" + } + }, + "node_modules/partysocket/node_modules/event-target-shim": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-6.0.2.tgz", + "integrity": "sha512-8q3LsZjRezbFZ2PN+uP+Q7pnHUMmAOziU2vA2OwoFaKIXxlxl38IylhSSgUorWu/rf4er67w0ikBqjBFk/pomA==", + "license": "MIT", + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -13830,12 +13851,6 @@ "node": ">=8.10.0" } }, - "node_modules/reconnecting-websocket": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/reconnecting-websocket/-/reconnecting-websocket-4.4.0.tgz", - "integrity": "sha512-D2E33ceRPga0NvTDhJmphEgJ7FUYF0v4lr1ki0csq06OdlxKfugGzN0dSkxM/NfqCxYELK4KcaTOUOjTV6Dcng==", - "license": "MIT" - }, "node_modules/regenerator-runtime": { "version": "0.14.1", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", diff --git a/package.json b/package.json index ee6b60b39..d12f65352 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "nprogress": "^0.2.0", "openskill": "^4.1.0", "p-limit": "^6.2.0", + "partysocket": "^1.1.2", "react": "^18.3.1", "react-aria-components": "^1.7.0", "react-charts": "^3.0.0-beta.57", @@ -71,7 +72,6 @@ "react-i18next": "^15.4.1", "react-use": "^17.6.0", "react-use-draggable-scroll": "^0.4.7", - "reconnecting-websocket": "^4.4.0", "remix-auth": "^4.1.0", "remix-auth-oauth2": "^3.2.2", "remix-i18next": "^6.4.1",