Skip to content

Commit

Permalink
Do not set websocket to null if in error state.
Browse files Browse the repository at this point in the history
  • Loading branch information
ProjectMoon committed Jul 30, 2024
1 parent f03f665 commit 84821d2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ui/components/ChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const useSocket = (
url: string,
setIsWSReady: (ready: boolean) => void,
setError: (error: boolean) => void,
hasError: boolean
) => {
const [ws, setWs] = useState<WebSocket | null>(null);

Expand Down Expand Up @@ -194,7 +195,9 @@ const useSocket = (

ws.onclose = () => {
clearTimeout(timeoutId);
setWs(null);
if (!hasError) {
setWs(null); // forces websocket to reopen when needed.
}
console.log('[DEBUG] closed');
};

Expand Down Expand Up @@ -285,6 +288,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
process.env.NEXT_PUBLIC_WS_URL!,
setIsWSReady,
setHasError,
hasError
);

const [loading, setLoading] = useState(false);
Expand Down

0 comments on commit 84821d2

Please sign in to comment.