Skip to content

Commit 87399d1

Browse files
authored
Fixed WS reconnection logic onError and onClose (#2591)
Removes duplicated reconnection request when error is reached on Object Browser websocket, also removed the use of the connect call back as it will contain references to the initial request and it is not necessary as we already have information available. Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent a01b855 commit 87399d1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

portal-ui/src/screens/Console/Buckets/BucketDetails/BrowserHandler.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const initWSConnection = (
121121

122122
const reconnectFn = () => {
123123
if (errorCounter <= 5) {
124-
initWSConnection(openCallback, onMessageCallback);
124+
initWSConnection(() => {}, onMessageCallback);
125125
errorCounter += 1;
126126
} else {
127127
console.error("Websocket not available.");
@@ -139,9 +139,7 @@ const initWSConnection = (
139139
objectsWS.onerror = () => {
140140
wsInFlight = false;
141141
console.error("Error in websocket connection. Attempting reconnection...");
142-
143-
// We reconnect after 3 seconds
144-
setTimeout(reconnectFn, 3000);
142+
// Onclose will be triggered by specification, reconnect function will be executed there to avoid duplicated requests
145143
};
146144
};
147145

0 commit comments

Comments
 (0)