@persistica/flux-agent 0.0.34 → 0.0.35
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.
- package/index.js +10 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -163,6 +163,7 @@ var WebSocketClient = class extends RPCServer {
|
|
|
163
163
|
this.options = {
|
|
164
164
|
autoReconnect: true,
|
|
165
165
|
reconnectDelay: 1e3,
|
|
166
|
+
maxReconnectDelay: 3e4,
|
|
166
167
|
heartbeatInterval: 6e4,
|
|
167
168
|
connectionTimeout: 5e3,
|
|
168
169
|
...options
|
|
@@ -242,12 +243,17 @@ var WebSocketClient = class extends RPCServer {
|
|
|
242
243
|
}
|
|
243
244
|
if (this.options.autoReconnect && (this.options.retries === void 0 || this.reconnectAttempts < this.options.retries)) {
|
|
244
245
|
const delay = wasKicked ? RECONNECTION_DELAY_ON_KICK_MS : Math.min(
|
|
245
|
-
this.options.
|
|
246
|
-
(this.options.reconnectDelay ?? 0) *
|
|
246
|
+
this.options.maxReconnectDelay ?? Number.POSITIVE_INFINITY,
|
|
247
|
+
(this.options.reconnectDelay ?? 0) * 2 ** this.reconnectAttempts
|
|
247
248
|
);
|
|
248
249
|
setTimeout(() => {
|
|
249
250
|
this.reconnectAttempts++;
|
|
250
|
-
|
|
251
|
+
this.connect().catch((error) => {
|
|
252
|
+
this.emit(
|
|
253
|
+
"error",
|
|
254
|
+
error instanceof Error ? error : new Error(String(error))
|
|
255
|
+
);
|
|
256
|
+
});
|
|
251
257
|
}, delay);
|
|
252
258
|
} else if (this.options.autoReconnect) {
|
|
253
259
|
this.emit("error", new Error("Connection failed: retries exhausted"));
|
|
@@ -831,7 +837,7 @@ var FluxWebSocketConnection = class {
|
|
|
831
837
|
});
|
|
832
838
|
this.socket.clearEventSubscribers();
|
|
833
839
|
this.socket.on("message", this.socketMessageHandler).on("close", this.socketCloseHandler).on("connecting", this.socketConnectingHandler).on("error", this.socketErrorHandler);
|
|
834
|
-
|
|
840
|
+
this.socket.connect().catch(this.socketErrorHandler);
|
|
835
841
|
return this.connectPromise;
|
|
836
842
|
}
|
|
837
843
|
/**
|