@replit/river 0.26.1 → 0.26.3
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/dist/{chunk-4W5LENT2.js → chunk-3JCZNGF7.js} +2 -2
- package/dist/{chunk-XRI2BXMM.js → chunk-BB2E5L4U.js} +25 -13
- package/dist/chunk-BB2E5L4U.js.map +1 -0
- package/dist/{chunk-6UVTCZ6K.js → chunk-JI6FFDY5.js} +5 -4
- package/dist/{chunk-6UVTCZ6K.js.map → chunk-JI6FFDY5.js.map} +1 -1
- package/dist/{chunk-UQOD22AN.js → chunk-MZELCWJK.js} +2 -2
- package/dist/{chunk-UQOD22AN.js.map → chunk-MZELCWJK.js.map} +1 -1
- package/dist/{chunk-M43R4RPL.js → chunk-OCL2FUTQ.js} +128 -45
- package/dist/chunk-OCL2FUTQ.js.map +1 -0
- package/dist/{chunk-IVNX5H6C.js → chunk-X35QRIA5.js} +54 -55
- package/dist/chunk-X35QRIA5.js.map +1 -0
- package/dist/{chunk-AYIMQWS7.js → chunk-ZY2HYJ5Y.js} +2 -2
- package/dist/{client-0f636b3a.d.ts → client-1894a9c9.d.ts} +2 -4
- package/dist/{connection-07e97a79.d.ts → connection-03ffb583.d.ts} +1 -1
- package/dist/{handshake-8752f79e.d.ts → handshake-154a0bb2.d.ts} +82 -39
- package/dist/logging/index.d.cts +1 -1
- package/dist/logging/index.d.ts +1 -1
- package/dist/{message-57296605.d.ts → message-ff78a233.d.ts} +1 -1
- package/dist/router/index.cjs +1 -1
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +9 -8
- package/dist/router/index.d.ts +9 -8
- package/dist/router/index.js +2 -2
- package/dist/{server-e304daec.d.ts → server-1f5eb427.d.ts} +27 -6
- package/dist/{services-fc99aae1.d.ts → services-491d8c32.d.ts} +3 -3
- package/dist/transport/impls/ws/client.cjs +153 -56
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +5 -4
- package/dist/transport/impls/ws/client.d.ts +5 -4
- package/dist/transport/impls/ws/client.js +8 -7
- package/dist/transport/impls/ws/client.js.map +1 -1
- package/dist/transport/impls/ws/server.cjs +179 -96
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +5 -4
- package/dist/transport/impls/ws/server.d.ts +5 -4
- package/dist/transport/impls/ws/server.js +5 -5
- package/dist/transport/index.cjs +200 -105
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +5 -4
- package/dist/transport/index.d.ts +5 -4
- package/dist/transport/index.js +5 -5
- package/dist/util/testHelpers.cjs +127 -44
- package/dist/util/testHelpers.cjs.map +1 -1
- package/dist/util/testHelpers.d.cts +5 -4
- package/dist/util/testHelpers.d.ts +5 -4
- package/dist/util/testHelpers.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-IVNX5H6C.js.map +0 -1
- package/dist/chunk-M43R4RPL.js.map +0 -1
- package/dist/chunk-XRI2BXMM.js.map +0 -1
- /package/dist/{chunk-4W5LENT2.js.map → chunk-3JCZNGF7.js.map} +0 -0
- /package/dist/{chunk-AYIMQWS7.js.map → chunk-ZY2HYJ5Y.js.map} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../handshake-
|
|
2
|
-
export { C as ClientTransport } from '../client-
|
|
3
|
-
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-
|
|
4
|
-
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-
|
|
1
|
+
export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../handshake-154a0bb2.js';
|
|
2
|
+
export { C as ClientTransport } from '../client-1894a9c9.js';
|
|
3
|
+
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-1f5eb427.js';
|
|
4
|
+
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-ff78a233.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
|
+
import '@sinclair/typebox/errors';
|
|
6
7
|
import '../types-3e5768ec.js';
|
|
7
8
|
import '@sinclair/typebox/value';
|
|
8
9
|
import '@opentelemetry/api';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../handshake-
|
|
2
|
-
export { C as ClientTransport } from '../client-
|
|
3
|
-
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-
|
|
4
|
-
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-
|
|
1
|
+
export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../handshake-154a0bb2.js';
|
|
2
|
+
export { C as ClientTransport } from '../client-1894a9c9.js';
|
|
3
|
+
export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-1f5eb427.js';
|
|
4
|
+
export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-ff78a233.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
|
+
import '@sinclair/typebox/errors';
|
|
6
7
|
import '../types-3e5768ec.js';
|
|
7
8
|
import '@sinclair/typebox/value';
|
|
8
9
|
import '@opentelemetry/api';
|
package/dist/transport/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientTransport
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-BB2E5L4U.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-X35QRIA5.js";
|
|
7
7
|
import {
|
|
8
8
|
Connection,
|
|
9
9
|
ProtocolError,
|
|
10
10
|
Transport
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-JI6FFDY5.js";
|
|
12
12
|
import "../chunk-TAH2GVTJ.js";
|
|
13
13
|
import {
|
|
14
14
|
SessionState
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-OCL2FUTQ.js";
|
|
16
16
|
import {
|
|
17
17
|
OpaqueTransportMessageSchema,
|
|
18
18
|
TransportMessageSchema
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-MZELCWJK.js";
|
|
20
20
|
import "../chunk-4PVU7J25.js";
|
|
21
21
|
export {
|
|
22
22
|
ClientTransport,
|
|
@@ -460,7 +460,7 @@ function Err(error) {
|
|
|
460
460
|
var import_api = require("@opentelemetry/api");
|
|
461
461
|
|
|
462
462
|
// package.json
|
|
463
|
-
var version = "0.26.
|
|
463
|
+
var version = "0.26.3";
|
|
464
464
|
|
|
465
465
|
// tracing/index.ts
|
|
466
466
|
function createSessionTelemetryInfo(sessionId, to, from, propagationCtx) {
|
|
@@ -549,6 +549,7 @@ var defaultTransportOptions = {
|
|
|
549
549
|
sessionDisconnectGraceMs: 5e3,
|
|
550
550
|
connectionTimeoutMs: 2e3,
|
|
551
551
|
handshakeTimeoutMs: 1e3,
|
|
552
|
+
enableTransparentSessionReconnects: true,
|
|
552
553
|
codec: NaiveJsonCodec
|
|
553
554
|
};
|
|
554
555
|
var defaultConnectionRetryOptions = {
|
|
@@ -593,6 +594,7 @@ var StateMachineState = class {
|
|
|
593
594
|
}
|
|
594
595
|
if (prop === "_handleClose") {
|
|
595
596
|
return () => {
|
|
597
|
+
target._isConsumed = true;
|
|
596
598
|
target._handleStateExit();
|
|
597
599
|
target._handleClose();
|
|
598
600
|
};
|
|
@@ -673,15 +675,18 @@ var IdentifiedSession = class extends CommonSession {
|
|
|
673
675
|
}
|
|
674
676
|
get loggingMetadata() {
|
|
675
677
|
const spanContext = this.telemetry.span.spanContext();
|
|
676
|
-
|
|
678
|
+
const metadata = {
|
|
677
679
|
clientId: this.from,
|
|
678
680
|
connectedTo: this.to,
|
|
679
|
-
sessionId: this.id
|
|
680
|
-
|
|
681
|
+
sessionId: this.id
|
|
682
|
+
};
|
|
683
|
+
if (this.telemetry.span.isRecording()) {
|
|
684
|
+
metadata.telemetry = {
|
|
681
685
|
traceId: spanContext.traceId,
|
|
682
686
|
spanId: spanContext.spanId
|
|
683
|
-
}
|
|
684
|
-
}
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
return metadata;
|
|
685
690
|
}
|
|
686
691
|
constructMsg(partialMsg) {
|
|
687
692
|
const msg = {
|
|
@@ -710,9 +715,32 @@ var IdentifiedSession = class extends CommonSession {
|
|
|
710
715
|
this.telemetry.span.end();
|
|
711
716
|
}
|
|
712
717
|
};
|
|
718
|
+
var IdentifiedSessionWithGracePeriod = class extends IdentifiedSession {
|
|
719
|
+
graceExpiryTime;
|
|
720
|
+
gracePeriodTimeout;
|
|
721
|
+
listeners;
|
|
722
|
+
constructor(props) {
|
|
723
|
+
super(props);
|
|
724
|
+
this.listeners = props.listeners;
|
|
725
|
+
this.graceExpiryTime = props.graceExpiryTime;
|
|
726
|
+
this.gracePeriodTimeout = setTimeout(() => {
|
|
727
|
+
this.listeners.onSessionGracePeriodElapsed();
|
|
728
|
+
}, this.graceExpiryTime - Date.now());
|
|
729
|
+
}
|
|
730
|
+
_handleStateExit() {
|
|
731
|
+
super._handleStateExit();
|
|
732
|
+
if (this.gracePeriodTimeout) {
|
|
733
|
+
clearTimeout(this.gracePeriodTimeout);
|
|
734
|
+
this.gracePeriodTimeout = void 0;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
_handleClose() {
|
|
738
|
+
super._handleClose();
|
|
739
|
+
}
|
|
740
|
+
};
|
|
713
741
|
|
|
714
742
|
// transport/sessionStateMachine/SessionConnecting.ts
|
|
715
|
-
var SessionConnecting = class extends
|
|
743
|
+
var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
|
|
716
744
|
state = "Connecting" /* Connecting */;
|
|
717
745
|
connPromise;
|
|
718
746
|
listeners;
|
|
@@ -740,13 +768,24 @@ var SessionConnecting = class extends IdentifiedSession {
|
|
|
740
768
|
// close a pending connection if it resolves, ignore errors if the promise
|
|
741
769
|
// ends up rejected anyways
|
|
742
770
|
bestEffortClose() {
|
|
743
|
-
void this.connPromise.then((conn) =>
|
|
771
|
+
void this.connPromise.then((conn) => {
|
|
772
|
+
conn.close();
|
|
773
|
+
this.log?.info(
|
|
774
|
+
"connection eventually resolved but session has transitioned, closed connection",
|
|
775
|
+
{
|
|
776
|
+
...this.loggingMetadata,
|
|
777
|
+
...conn.loggingMetadata
|
|
778
|
+
}
|
|
779
|
+
);
|
|
780
|
+
}).catch(() => {
|
|
744
781
|
});
|
|
745
782
|
}
|
|
746
783
|
_handleStateExit() {
|
|
747
784
|
super._handleStateExit();
|
|
748
|
-
|
|
749
|
-
|
|
785
|
+
if (this.connectionTimeout) {
|
|
786
|
+
clearTimeout(this.connectionTimeout);
|
|
787
|
+
this.connectionTimeout = void 0;
|
|
788
|
+
}
|
|
750
789
|
}
|
|
751
790
|
_handleClose() {
|
|
752
791
|
this.bestEffortClose();
|
|
@@ -755,26 +794,13 @@ var SessionConnecting = class extends IdentifiedSession {
|
|
|
755
794
|
};
|
|
756
795
|
|
|
757
796
|
// transport/sessionStateMachine/SessionNoConnection.ts
|
|
758
|
-
var SessionNoConnection = class extends
|
|
797
|
+
var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
|
|
759
798
|
state = "NoConnection" /* NoConnection */;
|
|
760
|
-
listeners;
|
|
761
|
-
gracePeriodTimeout;
|
|
762
|
-
constructor(props) {
|
|
763
|
-
super(props);
|
|
764
|
-
this.listeners = props.listeners;
|
|
765
|
-
this.gracePeriodTimeout = setTimeout(() => {
|
|
766
|
-
this.listeners.onSessionGracePeriodElapsed();
|
|
767
|
-
}, this.options.sessionDisconnectGraceMs);
|
|
768
|
-
}
|
|
769
799
|
_handleClose() {
|
|
770
800
|
super._handleClose();
|
|
771
801
|
}
|
|
772
802
|
_handleStateExit() {
|
|
773
803
|
super._handleStateExit();
|
|
774
|
-
if (this.gracePeriodTimeout) {
|
|
775
|
-
clearTimeout(this.gracePeriodTimeout);
|
|
776
|
-
this.gracePeriodTimeout = void 0;
|
|
777
|
-
}
|
|
778
804
|
}
|
|
779
805
|
};
|
|
780
806
|
|
|
@@ -795,6 +821,13 @@ var SessionWaitingForHandshake = class extends CommonSession {
|
|
|
795
821
|
this.conn.addErrorListener(this.listeners.onConnectionErrored);
|
|
796
822
|
this.conn.addCloseListener(this.listeners.onConnectionClosed);
|
|
797
823
|
}
|
|
824
|
+
get loggingMetadata() {
|
|
825
|
+
return {
|
|
826
|
+
clientId: this.from,
|
|
827
|
+
connId: this.conn.id,
|
|
828
|
+
...this.conn.loggingMetadata
|
|
829
|
+
};
|
|
830
|
+
}
|
|
798
831
|
onHandshakeData = (msg) => {
|
|
799
832
|
const parsedMsg = this.parseMsg(msg);
|
|
800
833
|
if (parsedMsg === null) {
|
|
@@ -806,12 +839,6 @@ var SessionWaitingForHandshake = class extends CommonSession {
|
|
|
806
839
|
}
|
|
807
840
|
this.listeners.onHandshake(parsedMsg);
|
|
808
841
|
};
|
|
809
|
-
get loggingMetadata() {
|
|
810
|
-
return {
|
|
811
|
-
clientId: this.from,
|
|
812
|
-
connId: this.conn.id
|
|
813
|
-
};
|
|
814
|
-
}
|
|
815
842
|
sendHandshake(msg) {
|
|
816
843
|
return this.conn.send(this.options.codec.toBuffer(msg));
|
|
817
844
|
}
|
|
@@ -828,7 +855,7 @@ var SessionWaitingForHandshake = class extends CommonSession {
|
|
|
828
855
|
};
|
|
829
856
|
|
|
830
857
|
// transport/sessionStateMachine/SessionHandshaking.ts
|
|
831
|
-
var SessionHandshaking = class extends
|
|
858
|
+
var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
|
|
832
859
|
state = "Handshaking" /* Handshaking */;
|
|
833
860
|
conn;
|
|
834
861
|
listeners;
|
|
@@ -844,6 +871,12 @@ var SessionHandshaking = class extends IdentifiedSession {
|
|
|
844
871
|
this.conn.addErrorListener(this.listeners.onConnectionErrored);
|
|
845
872
|
this.conn.addCloseListener(this.listeners.onConnectionClosed);
|
|
846
873
|
}
|
|
874
|
+
get loggingMetadata() {
|
|
875
|
+
return {
|
|
876
|
+
...super.loggingMetadata,
|
|
877
|
+
...this.conn.loggingMetadata
|
|
878
|
+
};
|
|
879
|
+
}
|
|
847
880
|
onHandshakeData = (msg) => {
|
|
848
881
|
const parsedMsg = this.parseMsg(msg);
|
|
849
882
|
if (parsedMsg === null) {
|
|
@@ -863,7 +896,10 @@ var SessionHandshaking = class extends IdentifiedSession {
|
|
|
863
896
|
this.conn.removeDataListener(this.onHandshakeData);
|
|
864
897
|
this.conn.removeErrorListener(this.listeners.onConnectionErrored);
|
|
865
898
|
this.conn.removeCloseListener(this.listeners.onConnectionClosed);
|
|
866
|
-
|
|
899
|
+
if (this.handshakeTimeout) {
|
|
900
|
+
clearTimeout(this.handshakeTimeout);
|
|
901
|
+
this.handshakeTimeout = void 0;
|
|
902
|
+
}
|
|
867
903
|
}
|
|
868
904
|
_handleClose() {
|
|
869
905
|
super._handleClose();
|
|
@@ -928,6 +964,12 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
928
964
|
this.heartbeatMisses++;
|
|
929
965
|
}, this.options.heartbeatIntervalMs);
|
|
930
966
|
}
|
|
967
|
+
get loggingMetadata() {
|
|
968
|
+
return {
|
|
969
|
+
...super.loggingMetadata,
|
|
970
|
+
...this.conn.loggingMetadata
|
|
971
|
+
};
|
|
972
|
+
}
|
|
931
973
|
startActiveHeartbeat() {
|
|
932
974
|
this.isActivelyHeartbeating = true;
|
|
933
975
|
}
|
|
@@ -943,8 +985,10 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
943
985
|
}
|
|
944
986
|
onMessageData = (msg) => {
|
|
945
987
|
const parsedMsg = this.parseMsg(msg);
|
|
946
|
-
if (parsedMsg === null)
|
|
988
|
+
if (parsedMsg === null) {
|
|
989
|
+
this.listeners.onInvalidMessage("could not parse message");
|
|
947
990
|
return;
|
|
991
|
+
}
|
|
948
992
|
if (parsedMsg.seq !== this.ack) {
|
|
949
993
|
if (parsedMsg.seq < this.ack) {
|
|
950
994
|
this.log?.debug(
|
|
@@ -1001,7 +1045,7 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
1001
1045
|
};
|
|
1002
1046
|
|
|
1003
1047
|
// transport/sessionStateMachine/SessionBackingOff.ts
|
|
1004
|
-
var SessionBackingOff = class extends
|
|
1048
|
+
var SessionBackingOff = class extends IdentifiedSessionWithGracePeriod {
|
|
1005
1049
|
state = "BackingOff" /* BackingOff */;
|
|
1006
1050
|
listeners;
|
|
1007
1051
|
backoffTimeout;
|
|
@@ -1038,6 +1082,12 @@ function inheritSharedSession(session) {
|
|
|
1038
1082
|
log: session.log
|
|
1039
1083
|
};
|
|
1040
1084
|
}
|
|
1085
|
+
function inheritSharedSessionWithGrace(session) {
|
|
1086
|
+
return {
|
|
1087
|
+
...inheritSharedSession(session),
|
|
1088
|
+
graceExpiryTime: session.graceExpiryTime
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1041
1091
|
var SessionStateGraph = {
|
|
1042
1092
|
entrypoints: {
|
|
1043
1093
|
NoConnection: (to, from, listeners, options, log) => {
|
|
@@ -1051,6 +1101,7 @@ var SessionStateGraph = {
|
|
|
1051
1101
|
to,
|
|
1052
1102
|
seq: 0,
|
|
1053
1103
|
ack: 0,
|
|
1104
|
+
graceExpiryTime: Date.now() + options.sessionDisconnectGraceMs,
|
|
1054
1105
|
sendBuffer,
|
|
1055
1106
|
telemetry,
|
|
1056
1107
|
options,
|
|
@@ -1082,7 +1133,7 @@ var SessionStateGraph = {
|
|
|
1082
1133
|
transition: {
|
|
1083
1134
|
// happy path transitions
|
|
1084
1135
|
NoConnectionToBackingOff: (oldSession, backoffMs, listeners) => {
|
|
1085
|
-
const carriedState =
|
|
1136
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
1086
1137
|
oldSession._handleStateExit();
|
|
1087
1138
|
const session = new SessionBackingOff({
|
|
1088
1139
|
backoffMs,
|
|
@@ -1099,7 +1150,7 @@ var SessionStateGraph = {
|
|
|
1099
1150
|
return session;
|
|
1100
1151
|
},
|
|
1101
1152
|
BackingOffToConnecting: (oldSession, connPromise, listeners) => {
|
|
1102
|
-
const carriedState =
|
|
1153
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
1103
1154
|
oldSession._handleStateExit();
|
|
1104
1155
|
const session = new SessionConnecting({
|
|
1105
1156
|
connPromise,
|
|
@@ -1116,7 +1167,7 @@ var SessionStateGraph = {
|
|
|
1116
1167
|
return session;
|
|
1117
1168
|
},
|
|
1118
1169
|
ConnectingToHandshaking: (oldSession, conn, listeners) => {
|
|
1119
|
-
const carriedState =
|
|
1170
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
1120
1171
|
oldSession._handleStateExit();
|
|
1121
1172
|
const session = new SessionHandshaking({
|
|
1122
1173
|
conn,
|
|
@@ -1193,9 +1244,12 @@ var SessionStateGraph = {
|
|
|
1193
1244
|
},
|
|
1194
1245
|
// disconnect paths
|
|
1195
1246
|
BackingOffToNoConnection: (oldSession, listeners) => {
|
|
1196
|
-
const carriedState =
|
|
1247
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
1197
1248
|
oldSession._handleStateExit();
|
|
1198
|
-
const session = new SessionNoConnection({
|
|
1249
|
+
const session = new SessionNoConnection({
|
|
1250
|
+
listeners,
|
|
1251
|
+
...carriedState
|
|
1252
|
+
});
|
|
1199
1253
|
session.log?.info(
|
|
1200
1254
|
`session ${session.id} transition from BackingOff to NoConnection`,
|
|
1201
1255
|
{
|
|
@@ -1206,10 +1260,13 @@ var SessionStateGraph = {
|
|
|
1206
1260
|
return session;
|
|
1207
1261
|
},
|
|
1208
1262
|
ConnectingToNoConnection: (oldSession, listeners) => {
|
|
1209
|
-
const carriedState =
|
|
1263
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
1210
1264
|
oldSession.bestEffortClose();
|
|
1211
1265
|
oldSession._handleStateExit();
|
|
1212
|
-
const session = new SessionNoConnection({
|
|
1266
|
+
const session = new SessionNoConnection({
|
|
1267
|
+
listeners,
|
|
1268
|
+
...carriedState
|
|
1269
|
+
});
|
|
1213
1270
|
session.log?.info(
|
|
1214
1271
|
`session ${session.id} transition from Connecting to NoConnection`,
|
|
1215
1272
|
{
|
|
@@ -1220,10 +1277,13 @@ var SessionStateGraph = {
|
|
|
1220
1277
|
return session;
|
|
1221
1278
|
},
|
|
1222
1279
|
HandshakingToNoConnection: (oldSession, listeners) => {
|
|
1223
|
-
const carriedState =
|
|
1280
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
1224
1281
|
oldSession.conn.close();
|
|
1225
1282
|
oldSession._handleStateExit();
|
|
1226
|
-
const session = new SessionNoConnection({
|
|
1283
|
+
const session = new SessionNoConnection({
|
|
1284
|
+
listeners,
|
|
1285
|
+
...carriedState
|
|
1286
|
+
});
|
|
1227
1287
|
session.log?.info(
|
|
1228
1288
|
`session ${session.id} transition from Handshaking to NoConnection`,
|
|
1229
1289
|
{
|
|
@@ -1235,9 +1295,14 @@ var SessionStateGraph = {
|
|
|
1235
1295
|
},
|
|
1236
1296
|
ConnectedToNoConnection: (oldSession, listeners) => {
|
|
1237
1297
|
const carriedState = inheritSharedSession(oldSession);
|
|
1298
|
+
const graceExpiryTime = Date.now() + oldSession.options.sessionDisconnectGraceMs;
|
|
1238
1299
|
oldSession.conn.close();
|
|
1239
1300
|
oldSession._handleStateExit();
|
|
1240
|
-
const session = new SessionNoConnection({
|
|
1301
|
+
const session = new SessionNoConnection({
|
|
1302
|
+
listeners,
|
|
1303
|
+
graceExpiryTime,
|
|
1304
|
+
...carriedState
|
|
1305
|
+
});
|
|
1241
1306
|
session.log?.info(
|
|
1242
1307
|
`session ${session.id} transition from Connected to NoConnection`,
|
|
1243
1308
|
{
|
|
@@ -1254,24 +1319,42 @@ var ClientSessionStateGraph = {
|
|
|
1254
1319
|
entrypoint: SessionStateGraph.entrypoints.NoConnection,
|
|
1255
1320
|
transition: {
|
|
1256
1321
|
// happy paths
|
|
1322
|
+
// NoConnection -> BackingOff: attempt to connect
|
|
1257
1323
|
NoConnectionToBackingOff: transitions.NoConnectionToBackingOff,
|
|
1324
|
+
// BackingOff -> Connecting: backoff period elapsed, start connection
|
|
1258
1325
|
BackingOffToConnecting: transitions.BackingOffToConnecting,
|
|
1326
|
+
// Connecting -> Handshaking: connection established, start handshake
|
|
1259
1327
|
ConnectingToHandshaking: transitions.ConnectingToHandshaking,
|
|
1328
|
+
// Handshaking -> Connected: handshake complete, session ready
|
|
1260
1329
|
HandshakingToConnected: transitions.HandshakingToConnected,
|
|
1261
1330
|
// disconnect paths
|
|
1331
|
+
// BackingOff -> NoConnection: unused
|
|
1262
1332
|
BackingOffToNoConnection: transitions.BackingOffToNoConnection,
|
|
1333
|
+
// Connecting -> NoConnection: connection failed or connection timeout
|
|
1263
1334
|
ConnectingToNoConnection: transitions.ConnectingToNoConnection,
|
|
1335
|
+
// Handshaking -> NoConnection: connection closed or handshake timeout
|
|
1264
1336
|
HandshakingToNoConnection: transitions.HandshakingToNoConnection,
|
|
1337
|
+
// Connected -> NoConnection: connection closed
|
|
1265
1338
|
ConnectedToNoConnection: transitions.ConnectedToNoConnection
|
|
1339
|
+
// destroy/close paths
|
|
1340
|
+
// NoConnection -> x: grace period elapsed
|
|
1341
|
+
// BackingOff -> x: grace period elapsed
|
|
1342
|
+
// Connecting -> x: grace period elapsed
|
|
1343
|
+
// Handshaking -> x: grace period elapsed or invalid handshake message or handshake rejection
|
|
1344
|
+
// Connected -> x: grace period elapsed or invalid message
|
|
1266
1345
|
}
|
|
1267
1346
|
};
|
|
1268
1347
|
var ServerSessionStateGraph = {
|
|
1269
1348
|
entrypoint: SessionStateGraph.entrypoints.WaitingForHandshake,
|
|
1270
1349
|
transition: {
|
|
1271
1350
|
// happy paths
|
|
1351
|
+
// WaitingForHandshake -> Connected: handshake complete, session ready
|
|
1272
1352
|
WaitingForHandshakeToConnected: transitions.WaitingForHandshakeToConnected,
|
|
1273
1353
|
// disconnect paths
|
|
1354
|
+
// Connected -> NoConnection: connection closed
|
|
1274
1355
|
ConnectedToNoConnection: transitions.ConnectedToNoConnection
|
|
1356
|
+
// destroy/close paths
|
|
1357
|
+
// WaitingForHandshake -> x: handshake timeout elapsed or invalid handshake message or handshake rejection or connection closed
|
|
1275
1358
|
}
|
|
1276
1359
|
};
|
|
1277
1360
|
|