better cleanup

This commit is contained in:
Adhiraj
2020-08-29 13:36:15 +05:30
parent 6311303773
commit 536d12a200
3 changed files with 35 additions and 4 deletions

View File

@@ -130,8 +130,10 @@ export const openWebSocketConnection = (timeoutMs: number, retryOnNetworkError:
while (!cancelled) {
try {
const ws = await newWS()
if (!cancelled) return ws
break
if (cancelled) {
ws.close ()
break
} else return ws
} catch (error) {
if (!retryOnNetworkError) throw error
await delay (1000)