Skip to content

Commit d5e8b6c

Browse files
committed
Prevent socket reconnections
1 parent 024f96d commit d5e8b6c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

web/src/hooks/useSocketIO.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ export function useSocketIO({
2323
// Only connect if we have a session token
2424
if (!sessionToken) {
2525
// Disconnect if we're connected but no longer have a token
26-
if (socketRef.current?.connected) {
26+
if (socketRef.current) {
2727
socketRef.current.disconnect();
28+
socketRef.current = null;
2829
}
2930
return;
3031
}
3132

32-
// Don't reconnect if already connected with the same token
33-
if (socketRef.current?.connected) {
33+
// Don't reconnect if a socket already exists (connected or connecting)
34+
if (socketRef.current) {
3435
return;
3536
}
3637

@@ -43,8 +44,7 @@ export function useSocketIO({
4344
reconnectionDelay: 10000,
4445
transports: ['polling', 'websocket'],
4546
timeout: 20000,
46-
path: configs.SOCKET_ENDPOINT,
47-
forceNew: true // Force new connection to prevent reusing stale connections
47+
path: configs.SOCKET_ENDPOINT
4848
});
4949

5050
socketRef.current = socket;

0 commit comments

Comments
 (0)