user 6 lat temu
rodzic
commit
4cb094b318
3 zmienionych plików z 15 dodań i 6 usunięć
  1. 8 3
      lib/index.js
  2. 1 1
      lib/index.js.map
  3. 6 2
      src/index.ts

+ 8 - 3
lib/index.js

@@ -398,9 +398,14 @@ class BankClient {
                 }
                 finally {
                     console.log('reconnecting in 5s');
-                    setTimeout(() => {
-                        this.connectWebsocket(peerAddr, topic, connectCallback, messageCallback);
-                    }, 5000);
+                    setTimeout(() => __awaiter(this, void 0, void 0, function* () {
+                        try {
+                            yield this.connectWebsocket(peerAddr, topic, connectCallback, messageCallback);
+                        }
+                        catch (e) {
+                            console.error('error reconnecting', e);
+                        }
+                    }), 5000);
                 }
             };
             ws.on('error', err => {

Plik diff jest za duży
+ 1 - 1
lib/index.js.map


+ 6 - 2
src/index.ts

@@ -397,8 +397,12 @@ export class BankClient {
           ws.terminate();
         } finally {
           console.log('reconnecting in 5s');
-          setTimeout(() => {
-            this.connectWebsocket(peerAddr, topic, connectCallback, messageCallback);
+          setTimeout(async () => {
+            try {
+              await this.connectWebsocket(peerAddr, topic, connectCallback, messageCallback);
+            } catch (e) {
+              console.error('error reconnecting', e);
+            }
           }, 5000);
         }
       };