File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments