@atomiqlabs/chain-evm 1.0.0-dev.55 → 1.0.0-dev.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,6 +14,7 @@ export declare class ReconnectingWebSocketProvider extends SocketProvider {
|
|
|
14
14
|
});
|
|
15
15
|
constructor(url: string, network?: Networkish, options?: JsonRpcApiProviderOptions);
|
|
16
16
|
private connect;
|
|
17
|
+
private disconnectedAndScheduleReconnect;
|
|
17
18
|
_write(message: string): Promise<void>;
|
|
18
19
|
destroy(): Promise<void>;
|
|
19
20
|
}
|
|
@@ -21,43 +21,39 @@ class ReconnectingWebSocketProvider extends SocketProvider_1.SocketProvider {
|
|
|
21
21
|
//Error
|
|
22
22
|
if (e.code === "NETWORK_ERROR") {
|
|
23
23
|
console.error("Websocket ping error: ", e);
|
|
24
|
-
this.websocket
|
|
24
|
+
if (this.websocket != null) {
|
|
25
|
+
this.websocket.close();
|
|
26
|
+
this.disconnectedAndScheduleReconnect();
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
});
|
|
27
30
|
}, this.pingIntervalSeconds * 1000);
|
|
28
31
|
};
|
|
29
32
|
this.websocket.onerror = (err) => {
|
|
30
33
|
console.error(`Websocket connection error: `, err);
|
|
31
|
-
|
|
32
|
-
return;
|
|
33
|
-
if (this.websocket == null)
|
|
34
|
-
return;
|
|
35
|
-
this.websocket = null;
|
|
36
|
-
if (this.pingInterval != null)
|
|
37
|
-
clearInterval(this.pingInterval);
|
|
38
|
-
//Fail all in-flight requests
|
|
39
|
-
this._disconnected();
|
|
40
|
-
console.error(`Retrying in ${this.reconnectSeconds} seconds...`);
|
|
41
|
-
this.reconnectTimer = setTimeout(() => this.connect(), this.reconnectSeconds * 1000);
|
|
34
|
+
this.disconnectedAndScheduleReconnect();
|
|
42
35
|
};
|
|
43
36
|
this.websocket.onmessage = (message) => {
|
|
44
37
|
this._processMessage(message.data);
|
|
45
38
|
};
|
|
46
39
|
this.websocket.onclose = (event) => {
|
|
47
40
|
console.error(`Websocket connection closed: `, event);
|
|
48
|
-
|
|
49
|
-
return;
|
|
50
|
-
if (this.websocket == null)
|
|
51
|
-
return;
|
|
52
|
-
this.websocket = null;
|
|
53
|
-
if (this.pingInterval != null)
|
|
54
|
-
clearInterval(this.pingInterval);
|
|
55
|
-
//Fail all in-flight requests
|
|
56
|
-
this._disconnected();
|
|
57
|
-
console.error(`Retrying in ${this.reconnectSeconds} seconds...`);
|
|
58
|
-
this.reconnectTimer = setTimeout(() => this.connect(), this.reconnectSeconds * 1000);
|
|
41
|
+
this.disconnectedAndScheduleReconnect();
|
|
59
42
|
};
|
|
60
43
|
}
|
|
44
|
+
disconnectedAndScheduleReconnect() {
|
|
45
|
+
if (this.destroyed)
|
|
46
|
+
return;
|
|
47
|
+
if (this.websocket == null)
|
|
48
|
+
return;
|
|
49
|
+
this.websocket = null;
|
|
50
|
+
if (this.pingInterval != null)
|
|
51
|
+
clearInterval(this.pingInterval);
|
|
52
|
+
//Fail all in-flight requests
|
|
53
|
+
this._disconnected();
|
|
54
|
+
console.error(`Retrying in ${this.reconnectSeconds} seconds...`);
|
|
55
|
+
this.reconnectTimer = setTimeout(() => this.connect(), this.reconnectSeconds * 1000);
|
|
56
|
+
}
|
|
61
57
|
async _write(message) {
|
|
62
58
|
this.websocket.send(message);
|
|
63
59
|
}
|
package/package.json
CHANGED
|
@@ -33,7 +33,10 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
|
|
|
33
33
|
//Error
|
|
34
34
|
if(e.code==="NETWORK_ERROR") {
|
|
35
35
|
console.error("Websocket ping error: ", e);
|
|
36
|
-
this.websocket
|
|
36
|
+
if(this.websocket!=null) {
|
|
37
|
+
this.websocket.close();
|
|
38
|
+
this.disconnectedAndScheduleReconnect();
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
});
|
|
39
42
|
}, this.pingIntervalSeconds * 1000);
|
|
@@ -41,16 +44,7 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
|
|
|
41
44
|
|
|
42
45
|
this.websocket.onerror = (err) => {
|
|
43
46
|
console.error(`Websocket connection error: `, err);
|
|
44
|
-
|
|
45
|
-
if(this.websocket==null) return;
|
|
46
|
-
this.websocket = null;
|
|
47
|
-
if(this.pingInterval!=null) clearInterval(this.pingInterval);
|
|
48
|
-
|
|
49
|
-
//Fail all in-flight requests
|
|
50
|
-
this._disconnected();
|
|
51
|
-
|
|
52
|
-
console.error(`Retrying in ${this.reconnectSeconds} seconds...`);
|
|
53
|
-
this.reconnectTimer = setTimeout(() => this.connect(), this.reconnectSeconds * 1000);
|
|
47
|
+
this.disconnectedAndScheduleReconnect();
|
|
54
48
|
};
|
|
55
49
|
|
|
56
50
|
this.websocket.onmessage = (message: { data: string }) => {
|
|
@@ -59,17 +53,21 @@ export class ReconnectingWebSocketProvider extends SocketProvider {
|
|
|
59
53
|
|
|
60
54
|
this.websocket.onclose = (event) => {
|
|
61
55
|
console.error(`Websocket connection closed: `, event);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if(this.pingInterval!=null) clearInterval(this.pingInterval);
|
|
56
|
+
this.disconnectedAndScheduleReconnect();
|
|
57
|
+
};
|
|
58
|
+
}
|
|
66
59
|
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
private disconnectedAndScheduleReconnect() {
|
|
61
|
+
if(this.destroyed) return;
|
|
62
|
+
if(this.websocket==null) return;
|
|
63
|
+
this.websocket = null;
|
|
64
|
+
if(this.pingInterval!=null) clearInterval(this.pingInterval);
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
//Fail all in-flight requests
|
|
67
|
+
this._disconnected();
|
|
68
|
+
|
|
69
|
+
console.error(`Retrying in ${this.reconnectSeconds} seconds...`);
|
|
70
|
+
this.reconnectTimer = setTimeout(() => this.connect(), this.reconnectSeconds * 1000);
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
async _write(message: string): Promise<void> {
|