@persistica/flux-agent 0.0.36 → 0.0.37
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 +17 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -726,6 +726,7 @@ var ChannelStateManager = class {
|
|
|
726
726
|
};
|
|
727
727
|
|
|
728
728
|
// libs/flux/shared/connection/src/lib/flux-ws-connection.ts
|
|
729
|
+
var RECONNECT_DELAY_MS = 2e3;
|
|
729
730
|
var createWSConnection = (id, ticket, stateManager, onReconnectCallback, options) => {
|
|
730
731
|
return new FluxWebSocketConnection(
|
|
731
732
|
id,
|
|
@@ -757,8 +758,11 @@ var FluxWebSocketConnection = class {
|
|
|
757
758
|
this.socket = new FluxWebSocketClientConnection(
|
|
758
759
|
{
|
|
759
760
|
url: url.toString(),
|
|
760
|
-
|
|
761
|
-
|
|
761
|
+
// The URL carries a mesh-issued ticket that expires (15 minutes)
|
|
762
|
+
// long before this connection does. Re-dialling it is pointless —
|
|
763
|
+
// the mesh answers 'jwt expired' every time — so coming back is
|
|
764
|
+
// `onReconnectCallback`'s job: it signs on again from scratch.
|
|
765
|
+
autoReconnect: false,
|
|
762
766
|
retries: this.options.retries
|
|
763
767
|
}
|
|
764
768
|
);
|
|
@@ -780,18 +784,12 @@ var FluxWebSocketConnection = class {
|
|
|
780
784
|
webSocketClient;
|
|
781
785
|
connectPromise;
|
|
782
786
|
connectPromiseResolver;
|
|
783
|
-
first = true;
|
|
784
787
|
channelStateManager = new ChannelStateManager();
|
|
785
788
|
// ****************************************************************************
|
|
786
789
|
// *** Reused socket callbacks
|
|
787
790
|
// ****************************************************************************
|
|
788
791
|
readyInterceptor = () => {
|
|
789
792
|
this.resolveConnectedSocket();
|
|
790
|
-
if (this.first) {
|
|
791
|
-
this.first = false;
|
|
792
|
-
return;
|
|
793
|
-
}
|
|
794
|
-
this.onReconnectCallback();
|
|
795
793
|
};
|
|
796
794
|
socketMessageHandler = this.handleMessage.bind(this);
|
|
797
795
|
socketCloseHandler = (reason) => this.handleSocketClose(reason);
|
|
@@ -976,6 +974,17 @@ var FluxWebSocketConnection = class {
|
|
|
976
974
|
this.fluxInstanceId
|
|
977
975
|
);
|
|
978
976
|
this.stateManager.emitNetworkState(reason === "kicked" ? "kicked" : "disconnected");
|
|
977
|
+
setTimeout(
|
|
978
|
+
() => {
|
|
979
|
+
Promise.resolve(this.onReconnectCallback()).catch((error) => {
|
|
980
|
+
PicoLogger.error(
|
|
981
|
+
`Failed to sign on again: ${error instanceof Error ? error.message : String(error)}`,
|
|
982
|
+
this.fluxInstanceId
|
|
983
|
+
);
|
|
984
|
+
});
|
|
985
|
+
},
|
|
986
|
+
reason === "kicked" ? RECONNECTION_DELAY_ON_KICK_MS : RECONNECT_DELAY_MS
|
|
987
|
+
);
|
|
979
988
|
}
|
|
980
989
|
handleSocketConnecting(retryAttempt) {
|
|
981
990
|
this.stateManager.emitNetworkState("connecting");
|