Open nttoan26 opened 4 years ago
Work-around solution: call socket.close() on (maxRetries - 1) retrying attempt to prevent last attempt
socket.addEventListener('error', (e) => {
console.log('[WS] error', socket.retryCount);
if (socket.retryCount >= maxRetries) {
store.dispatch({ type: Action.ACTION_SHOW_ERROR, msg: 'Notifications are unavailable' });
socket.close();
socket = null;
}
});
hence set maxRetries = desired maxRetries + 1
const maxRetries = 3; const options = { maxRetries: maxRetries + 1 };
How can I know whether a retrying is the last time or not, so I can display an error msg to user ? If there is no way then this should be an enhancement.
Updated: socket._retryCount get increased on every retrying except the last time, so it's useless