Skip to content

Commit e819f6d

Browse files
committed
Increase reconnect settings for based WS and logs
1 parent 51aeb0c commit e819f6d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

packages/ui/src/search/Search/Search.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,19 @@ const Search = forwardRef(
104104
}, [wssUrl]);
105105

106106
const { lastMessage, readyState } = useWebSocket(getSocketUrl, {
107-
shouldReconnect: (closeEvent) => true
107+
shouldReconnect: (closeEvent) => true,
108+
reconnectAttempts: 1000,
109+
reconnectInterval: 1000,
110+
onError: (event) => {
111+
console.error('Error connecting to ws', event);
112+
},
113+
onOpen: (event) => {
114+
console.info('Connected to ws', event);
115+
},
116+
onReconnectStop: (event) => {
117+
console.info('Stopped reconnecting to ws', event);
118+
},
119+
retryOnError: true
108120
});
109121

110122
const wsReady = readyState === ReadyState.OPEN;
@@ -231,6 +243,10 @@ const Search = forwardRef(
231243
const message = JSON.parse(lastMessage.data);
232244
const { event, payload } = message;
233245

246+
if (process.env.NODE_ENV === 'development') {
247+
console.info('Received ws message', message);
248+
}
249+
234250
if (event.includes(WS_EVENTS.API.RUN_CALLBACK)) {
235251
runEventCallback(payload.runningItemId, payload.listItemId)(
236252
payload.event,
@@ -272,7 +288,9 @@ const Search = forwardRef(
272288
setWssUrl(newWsUrl);
273289
});
274290
}
275-
} catch {}
291+
} catch (error) {
292+
console.warn('Failed to connect to wss via backend API', error);
293+
}
276294
});
277295

278296
return (

0 commit comments

Comments
 (0)