@replit/river 0.26.0 → 0.26.2
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-KP4UB5NW.js → chunk-AWCUCZY4.js} +2 -2
- package/dist/{chunk-5S64PXTU.js → chunk-IV27BICV.js} +36 -9
- package/dist/chunk-IV27BICV.js.map +1 -0
- package/dist/{chunk-5FDAIAQ5.js → chunk-M5X4JTU3.js} +5 -5
- package/dist/chunk-M5X4JTU3.js.map +1 -0
- package/dist/{chunk-CCUYKR5C.js → chunk-M75K5TJS.js} +2 -2
- package/dist/{chunk-CCUYKR5C.js.map → chunk-M75K5TJS.js.map} +1 -1
- package/dist/{chunk-BNNELZM4.js → chunk-MREEJE3X.js} +2 -2
- package/dist/{chunk-JSU2KACV.js → chunk-NC54BC47.js} +98 -35
- package/dist/chunk-NC54BC47.js.map +1 -0
- package/dist/{chunk-7ETNUCOL.js → chunk-YQABPD3C.js} +29 -14
- package/dist/chunk-YQABPD3C.js.map +1 -0
- package/dist/{client-162c509c.d.ts → client-654098be.d.ts} +2 -4
- package/dist/{connection-6a404bb8.d.ts → connection-bc2454dc.d.ts} +1 -1
- package/dist/{handshake-3342bb94.d.ts → handshake-1a86f06d.d.ts} +60 -42
- package/dist/logging/index.d.cts +1 -1
- package/dist/logging/index.d.ts +1 -1
- package/dist/{message-1a434848.d.ts → message-57296605.d.ts} +2 -1
- package/dist/router/index.cjs +1 -1
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +8 -8
- package/dist/router/index.d.ts +8 -8
- package/dist/router/index.js +2 -2
- package/dist/{server-1b695374.d.ts → server-9a6b5a8e.d.ts} +12 -4
- package/dist/{services-c17f7eff.d.ts → services-7daa60a0.d.ts} +3 -3
- package/dist/transport/impls/ws/client.cjs +131 -41
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +4 -4
- package/dist/transport/impls/ws/client.d.ts +4 -4
- package/dist/transport/impls/ws/client.js +5 -5
- package/dist/transport/impls/ws/server.cjs +124 -46
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +4 -4
- package/dist/transport/impls/ws/server.d.ts +4 -4
- package/dist/transport/impls/ws/server.js +5 -5
- package/dist/transport/index.cjs +156 -51
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +4 -4
- package/dist/transport/index.d.ts +4 -4
- package/dist/transport/index.js +5 -5
- package/dist/util/testHelpers.cjs +97 -34
- package/dist/util/testHelpers.cjs.map +1 -1
- package/dist/util/testHelpers.d.cts +4 -4
- package/dist/util/testHelpers.d.ts +4 -4
- package/dist/util/testHelpers.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-5FDAIAQ5.js.map +0 -1
- package/dist/chunk-5S64PXTU.js.map +0 -1
- package/dist/chunk-7ETNUCOL.js.map +0 -1
- package/dist/chunk-JSU2KACV.js.map +0 -1
- /package/dist/{chunk-KP4UB5NW.js.map → chunk-AWCUCZY4.js.map} +0 -0
- /package/dist/{chunk-BNNELZM4.js.map → chunk-MREEJE3X.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as ClientTransport } from '../../../client-
|
|
2
|
-
import { c as TransportClientId } from '../../../message-
|
|
3
|
-
import { b as ProvidedClientTransportOptions } from '../../../handshake-
|
|
4
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
1
|
+
import { C as ClientTransport } from '../../../client-654098be.js';
|
|
2
|
+
import { c as TransportClientId } from '../../../message-57296605.js';
|
|
3
|
+
import { b as ProvidedClientTransportOptions } from '../../../handshake-1a86f06d.js';
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-bc2454dc.js';
|
|
5
5
|
import { W as WsLike } from '../../../wslike-e0b32dd5.js';
|
|
6
6
|
import '@sinclair/typebox/value';
|
|
7
7
|
import '@sinclair/typebox';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as ClientTransport } from '../../../client-
|
|
2
|
-
import { c as TransportClientId } from '../../../message-
|
|
3
|
-
import { b as ProvidedClientTransportOptions } from '../../../handshake-
|
|
4
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
1
|
+
import { C as ClientTransport } from '../../../client-654098be.js';
|
|
2
|
+
import { c as TransportClientId } from '../../../message-57296605.js';
|
|
3
|
+
import { b as ProvidedClientTransportOptions } from '../../../handshake-1a86f06d.js';
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-bc2454dc.js';
|
|
5
5
|
import { W as WsLike } from '../../../wslike-e0b32dd5.js';
|
|
6
6
|
import '@sinclair/typebox/value';
|
|
7
7
|
import '@sinclair/typebox';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientTransport
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-IV27BICV.js";
|
|
4
4
|
import {
|
|
5
5
|
WebSocketConnection
|
|
6
|
-
} from "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
6
|
+
} from "../../../chunk-AWCUCZY4.js";
|
|
7
|
+
import "../../../chunk-M5X4JTU3.js";
|
|
8
8
|
import "../../../chunk-TAH2GVTJ.js";
|
|
9
|
-
import "../../../chunk-
|
|
10
|
-
import "../../../chunk-
|
|
9
|
+
import "../../../chunk-NC54BC47.js";
|
|
10
|
+
import "../../../chunk-M75K5TJS.js";
|
|
11
11
|
import "../../../chunk-4PVU7J25.js";
|
|
12
12
|
|
|
13
13
|
// transport/impls/ws/client.ts
|
|
@@ -322,6 +322,7 @@ var defaultTransportOptions = {
|
|
|
322
322
|
sessionDisconnectGraceMs: 5e3,
|
|
323
323
|
connectionTimeoutMs: 2e3,
|
|
324
324
|
handshakeTimeoutMs: 1e3,
|
|
325
|
+
enableTransparentSessionReconnects: true,
|
|
325
326
|
codec: NaiveJsonCodec
|
|
326
327
|
};
|
|
327
328
|
var defaultConnectionRetryOptions = {
|
|
@@ -573,9 +574,32 @@ var IdentifiedSession = class extends CommonSession {
|
|
|
573
574
|
this.telemetry.span.end();
|
|
574
575
|
}
|
|
575
576
|
};
|
|
577
|
+
var IdentifiedSessionWithGracePeriod = class extends IdentifiedSession {
|
|
578
|
+
graceExpiryTime;
|
|
579
|
+
gracePeriodTimeout;
|
|
580
|
+
listeners;
|
|
581
|
+
constructor(props) {
|
|
582
|
+
super(props);
|
|
583
|
+
this.listeners = props.listeners;
|
|
584
|
+
this.graceExpiryTime = props.graceExpiryTime;
|
|
585
|
+
this.gracePeriodTimeout = setTimeout(() => {
|
|
586
|
+
this.listeners.onSessionGracePeriodElapsed();
|
|
587
|
+
}, this.graceExpiryTime - Date.now());
|
|
588
|
+
}
|
|
589
|
+
_handleStateExit() {
|
|
590
|
+
super._handleStateExit();
|
|
591
|
+
if (this.gracePeriodTimeout) {
|
|
592
|
+
clearTimeout(this.gracePeriodTimeout);
|
|
593
|
+
this.gracePeriodTimeout = void 0;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
_handleClose() {
|
|
597
|
+
super._handleClose();
|
|
598
|
+
}
|
|
599
|
+
};
|
|
576
600
|
|
|
577
601
|
// transport/sessionStateMachine/SessionConnecting.ts
|
|
578
|
-
var SessionConnecting = class extends
|
|
602
|
+
var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
|
|
579
603
|
state = "Connecting" /* Connecting */;
|
|
580
604
|
connPromise;
|
|
581
605
|
listeners;
|
|
@@ -608,8 +632,10 @@ var SessionConnecting = class extends IdentifiedSession {
|
|
|
608
632
|
}
|
|
609
633
|
_handleStateExit() {
|
|
610
634
|
super._handleStateExit();
|
|
611
|
-
|
|
612
|
-
|
|
635
|
+
if (this.connectionTimeout) {
|
|
636
|
+
clearTimeout(this.connectionTimeout);
|
|
637
|
+
this.connectionTimeout = void 0;
|
|
638
|
+
}
|
|
613
639
|
}
|
|
614
640
|
_handleClose() {
|
|
615
641
|
this.bestEffortClose();
|
|
@@ -618,26 +644,13 @@ var SessionConnecting = class extends IdentifiedSession {
|
|
|
618
644
|
};
|
|
619
645
|
|
|
620
646
|
// transport/sessionStateMachine/SessionNoConnection.ts
|
|
621
|
-
var SessionNoConnection = class extends
|
|
647
|
+
var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
|
|
622
648
|
state = "NoConnection" /* NoConnection */;
|
|
623
|
-
listeners;
|
|
624
|
-
gracePeriodTimeout;
|
|
625
|
-
constructor(props) {
|
|
626
|
-
super(props);
|
|
627
|
-
this.listeners = props.listeners;
|
|
628
|
-
this.gracePeriodTimeout = setTimeout(() => {
|
|
629
|
-
this.listeners.onSessionGracePeriodElapsed();
|
|
630
|
-
}, this.options.sessionDisconnectGraceMs);
|
|
631
|
-
}
|
|
632
649
|
_handleClose() {
|
|
633
650
|
super._handleClose();
|
|
634
651
|
}
|
|
635
652
|
_handleStateExit() {
|
|
636
653
|
super._handleStateExit();
|
|
637
|
-
if (this.gracePeriodTimeout) {
|
|
638
|
-
clearTimeout(this.gracePeriodTimeout);
|
|
639
|
-
this.gracePeriodTimeout = void 0;
|
|
640
|
-
}
|
|
641
654
|
}
|
|
642
655
|
};
|
|
643
656
|
|
|
@@ -645,7 +658,7 @@ var SessionNoConnection = class extends IdentifiedSession {
|
|
|
645
658
|
var import_api = require("@opentelemetry/api");
|
|
646
659
|
|
|
647
660
|
// package.json
|
|
648
|
-
var version = "0.26.
|
|
661
|
+
var version = "0.26.2";
|
|
649
662
|
|
|
650
663
|
// tracing/index.ts
|
|
651
664
|
function createSessionTelemetryInfo(sessionId, to, from, propagationCtx) {
|
|
@@ -687,7 +700,10 @@ var SessionWaitingForHandshake = class extends CommonSession {
|
|
|
687
700
|
onHandshakeData = (msg) => {
|
|
688
701
|
const parsedMsg = this.parseMsg(msg);
|
|
689
702
|
if (parsedMsg === null) {
|
|
690
|
-
this.listeners.onInvalidHandshake(
|
|
703
|
+
this.listeners.onInvalidHandshake(
|
|
704
|
+
"could not parse message",
|
|
705
|
+
"MALFORMED_HANDSHAKE"
|
|
706
|
+
);
|
|
691
707
|
return;
|
|
692
708
|
}
|
|
693
709
|
this.listeners.onHandshake(parsedMsg);
|
|
@@ -714,7 +730,7 @@ var SessionWaitingForHandshake = class extends CommonSession {
|
|
|
714
730
|
};
|
|
715
731
|
|
|
716
732
|
// transport/sessionStateMachine/SessionHandshaking.ts
|
|
717
|
-
var SessionHandshaking = class extends
|
|
733
|
+
var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
|
|
718
734
|
state = "Handshaking" /* Handshaking */;
|
|
719
735
|
conn;
|
|
720
736
|
listeners;
|
|
@@ -733,7 +749,10 @@ var SessionHandshaking = class extends IdentifiedSession {
|
|
|
733
749
|
onHandshakeData = (msg) => {
|
|
734
750
|
const parsedMsg = this.parseMsg(msg);
|
|
735
751
|
if (parsedMsg === null) {
|
|
736
|
-
this.listeners.onInvalidHandshake(
|
|
752
|
+
this.listeners.onInvalidHandshake(
|
|
753
|
+
"could not parse message",
|
|
754
|
+
"MALFORMED_HANDSHAKE"
|
|
755
|
+
);
|
|
737
756
|
return;
|
|
738
757
|
}
|
|
739
758
|
this.listeners.onHandshake(parsedMsg);
|
|
@@ -746,7 +765,10 @@ var SessionHandshaking = class extends IdentifiedSession {
|
|
|
746
765
|
this.conn.removeDataListener(this.onHandshakeData);
|
|
747
766
|
this.conn.removeErrorListener(this.listeners.onConnectionErrored);
|
|
748
767
|
this.conn.removeCloseListener(this.listeners.onConnectionClosed);
|
|
749
|
-
|
|
768
|
+
if (this.handshakeTimeout) {
|
|
769
|
+
clearTimeout(this.handshakeTimeout);
|
|
770
|
+
this.handshakeTimeout = void 0;
|
|
771
|
+
}
|
|
750
772
|
}
|
|
751
773
|
_handleClose() {
|
|
752
774
|
super._handleClose();
|
|
@@ -826,8 +848,10 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
826
848
|
}
|
|
827
849
|
onMessageData = (msg) => {
|
|
828
850
|
const parsedMsg = this.parseMsg(msg);
|
|
829
|
-
if (parsedMsg === null)
|
|
851
|
+
if (parsedMsg === null) {
|
|
852
|
+
this.listeners.onInvalidMessage("could not parse message");
|
|
830
853
|
return;
|
|
854
|
+
}
|
|
831
855
|
if (parsedMsg.seq !== this.ack) {
|
|
832
856
|
if (parsedMsg.seq < this.ack) {
|
|
833
857
|
this.log?.debug(
|
|
@@ -884,7 +908,7 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
884
908
|
};
|
|
885
909
|
|
|
886
910
|
// transport/sessionStateMachine/SessionBackingOff.ts
|
|
887
|
-
var SessionBackingOff = class extends
|
|
911
|
+
var SessionBackingOff = class extends IdentifiedSessionWithGracePeriod {
|
|
888
912
|
state = "BackingOff" /* BackingOff */;
|
|
889
913
|
listeners;
|
|
890
914
|
backoffTimeout;
|
|
@@ -921,6 +945,12 @@ function inheritSharedSession(session) {
|
|
|
921
945
|
log: session.log
|
|
922
946
|
};
|
|
923
947
|
}
|
|
948
|
+
function inheritSharedSessionWithGrace(session) {
|
|
949
|
+
return {
|
|
950
|
+
...inheritSharedSession(session),
|
|
951
|
+
graceExpiryTime: session.graceExpiryTime
|
|
952
|
+
};
|
|
953
|
+
}
|
|
924
954
|
var SessionStateGraph = {
|
|
925
955
|
entrypoints: {
|
|
926
956
|
NoConnection: (to, from, listeners, options, log) => {
|
|
@@ -934,6 +964,7 @@ var SessionStateGraph = {
|
|
|
934
964
|
to,
|
|
935
965
|
seq: 0,
|
|
936
966
|
ack: 0,
|
|
967
|
+
graceExpiryTime: Date.now() + options.sessionDisconnectGraceMs,
|
|
937
968
|
sendBuffer,
|
|
938
969
|
telemetry,
|
|
939
970
|
options,
|
|
@@ -965,7 +996,7 @@ var SessionStateGraph = {
|
|
|
965
996
|
transition: {
|
|
966
997
|
// happy path transitions
|
|
967
998
|
NoConnectionToBackingOff: (oldSession, backoffMs, listeners) => {
|
|
968
|
-
const carriedState =
|
|
999
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
969
1000
|
oldSession._handleStateExit();
|
|
970
1001
|
const session = new SessionBackingOff({
|
|
971
1002
|
backoffMs,
|
|
@@ -982,7 +1013,7 @@ var SessionStateGraph = {
|
|
|
982
1013
|
return session;
|
|
983
1014
|
},
|
|
984
1015
|
BackingOffToConnecting: (oldSession, connPromise, listeners) => {
|
|
985
|
-
const carriedState =
|
|
1016
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
986
1017
|
oldSession._handleStateExit();
|
|
987
1018
|
const session = new SessionConnecting({
|
|
988
1019
|
connPromise,
|
|
@@ -999,7 +1030,7 @@ var SessionStateGraph = {
|
|
|
999
1030
|
return session;
|
|
1000
1031
|
},
|
|
1001
1032
|
ConnectingToHandshaking: (oldSession, conn, listeners) => {
|
|
1002
|
-
const carriedState =
|
|
1033
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
1003
1034
|
oldSession._handleStateExit();
|
|
1004
1035
|
const session = new SessionHandshaking({
|
|
1005
1036
|
conn,
|
|
@@ -1076,9 +1107,12 @@ var SessionStateGraph = {
|
|
|
1076
1107
|
},
|
|
1077
1108
|
// disconnect paths
|
|
1078
1109
|
BackingOffToNoConnection: (oldSession, listeners) => {
|
|
1079
|
-
const carriedState =
|
|
1110
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
1080
1111
|
oldSession._handleStateExit();
|
|
1081
|
-
const session = new SessionNoConnection({
|
|
1112
|
+
const session = new SessionNoConnection({
|
|
1113
|
+
listeners,
|
|
1114
|
+
...carriedState
|
|
1115
|
+
});
|
|
1082
1116
|
session.log?.info(
|
|
1083
1117
|
`session ${session.id} transition from BackingOff to NoConnection`,
|
|
1084
1118
|
{
|
|
@@ -1089,10 +1123,13 @@ var SessionStateGraph = {
|
|
|
1089
1123
|
return session;
|
|
1090
1124
|
},
|
|
1091
1125
|
ConnectingToNoConnection: (oldSession, listeners) => {
|
|
1092
|
-
const carriedState =
|
|
1126
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
1093
1127
|
oldSession.bestEffortClose();
|
|
1094
1128
|
oldSession._handleStateExit();
|
|
1095
|
-
const session = new SessionNoConnection({
|
|
1129
|
+
const session = new SessionNoConnection({
|
|
1130
|
+
listeners,
|
|
1131
|
+
...carriedState
|
|
1132
|
+
});
|
|
1096
1133
|
session.log?.info(
|
|
1097
1134
|
`session ${session.id} transition from Connecting to NoConnection`,
|
|
1098
1135
|
{
|
|
@@ -1103,10 +1140,13 @@ var SessionStateGraph = {
|
|
|
1103
1140
|
return session;
|
|
1104
1141
|
},
|
|
1105
1142
|
HandshakingToNoConnection: (oldSession, listeners) => {
|
|
1106
|
-
const carriedState =
|
|
1143
|
+
const carriedState = inheritSharedSessionWithGrace(oldSession);
|
|
1107
1144
|
oldSession.conn.close();
|
|
1108
1145
|
oldSession._handleStateExit();
|
|
1109
|
-
const session = new SessionNoConnection({
|
|
1146
|
+
const session = new SessionNoConnection({
|
|
1147
|
+
listeners,
|
|
1148
|
+
...carriedState
|
|
1149
|
+
});
|
|
1110
1150
|
session.log?.info(
|
|
1111
1151
|
`session ${session.id} transition from Handshaking to NoConnection`,
|
|
1112
1152
|
{
|
|
@@ -1118,9 +1158,14 @@ var SessionStateGraph = {
|
|
|
1118
1158
|
},
|
|
1119
1159
|
ConnectedToNoConnection: (oldSession, listeners) => {
|
|
1120
1160
|
const carriedState = inheritSharedSession(oldSession);
|
|
1161
|
+
const graceExpiryTime = Date.now() + oldSession.options.sessionDisconnectGraceMs;
|
|
1121
1162
|
oldSession.conn.close();
|
|
1122
1163
|
oldSession._handleStateExit();
|
|
1123
|
-
const session = new SessionNoConnection({
|
|
1164
|
+
const session = new SessionNoConnection({
|
|
1165
|
+
listeners,
|
|
1166
|
+
graceExpiryTime,
|
|
1167
|
+
...carriedState
|
|
1168
|
+
});
|
|
1124
1169
|
session.log?.info(
|
|
1125
1170
|
`session ${session.id} transition from Connected to NoConnection`,
|
|
1126
1171
|
{
|
|
@@ -1137,24 +1182,42 @@ var ClientSessionStateGraph = {
|
|
|
1137
1182
|
entrypoint: SessionStateGraph.entrypoints.NoConnection,
|
|
1138
1183
|
transition: {
|
|
1139
1184
|
// happy paths
|
|
1185
|
+
// NoConnection -> BackingOff: attempt to connect
|
|
1140
1186
|
NoConnectionToBackingOff: transitions.NoConnectionToBackingOff,
|
|
1187
|
+
// BackingOff -> Connecting: backoff period elapsed, start connection
|
|
1141
1188
|
BackingOffToConnecting: transitions.BackingOffToConnecting,
|
|
1189
|
+
// Connecting -> Handshaking: connection established, start handshake
|
|
1142
1190
|
ConnectingToHandshaking: transitions.ConnectingToHandshaking,
|
|
1191
|
+
// Handshaking -> Connected: handshake complete, session ready
|
|
1143
1192
|
HandshakingToConnected: transitions.HandshakingToConnected,
|
|
1144
1193
|
// disconnect paths
|
|
1194
|
+
// BackingOff -> NoConnection: unused
|
|
1145
1195
|
BackingOffToNoConnection: transitions.BackingOffToNoConnection,
|
|
1196
|
+
// Connecting -> NoConnection: connection failed or connection timeout
|
|
1146
1197
|
ConnectingToNoConnection: transitions.ConnectingToNoConnection,
|
|
1198
|
+
// Handshaking -> NoConnection: connection closed or handshake timeout
|
|
1147
1199
|
HandshakingToNoConnection: transitions.HandshakingToNoConnection,
|
|
1200
|
+
// Connected -> NoConnection: connection closed
|
|
1148
1201
|
ConnectedToNoConnection: transitions.ConnectedToNoConnection
|
|
1202
|
+
// destroy/close paths
|
|
1203
|
+
// NoConnection -> x: grace period elapsed
|
|
1204
|
+
// BackingOff -> x: grace period elapsed
|
|
1205
|
+
// Connecting -> x: grace period elapsed
|
|
1206
|
+
// Handshaking -> x: grace period elapsed or invalid handshake message or handshake rejection
|
|
1207
|
+
// Connected -> x: grace period elapsed or invalid message
|
|
1149
1208
|
}
|
|
1150
1209
|
};
|
|
1151
1210
|
var ServerSessionStateGraph = {
|
|
1152
1211
|
entrypoint: SessionStateGraph.entrypoints.WaitingForHandshake,
|
|
1153
1212
|
transition: {
|
|
1154
1213
|
// happy paths
|
|
1214
|
+
// WaitingForHandshake -> Connected: handshake complete, session ready
|
|
1155
1215
|
WaitingForHandshakeToConnected: transitions.WaitingForHandshakeToConnected,
|
|
1156
1216
|
// disconnect paths
|
|
1217
|
+
// Connected -> NoConnection: connection closed
|
|
1157
1218
|
ConnectedToNoConnection: transitions.ConnectedToNoConnection
|
|
1219
|
+
// destroy/close paths
|
|
1220
|
+
// WaitingForHandshake -> x: handshake timeout elapsed or invalid handshake message or handshake rejection or connection closed
|
|
1158
1221
|
}
|
|
1159
1222
|
};
|
|
1160
1223
|
|
|
@@ -1223,8 +1286,8 @@ var Transport = class {
|
|
|
1223
1286
|
removeEventListener(type, handler) {
|
|
1224
1287
|
this.eventDispatcher.removeEventListener(type, handler);
|
|
1225
1288
|
}
|
|
1226
|
-
protocolError(
|
|
1227
|
-
this.eventDispatcher.dispatchEvent("protocolError",
|
|
1289
|
+
protocolError(message) {
|
|
1290
|
+
this.eventDispatcher.dispatchEvent("protocolError", message);
|
|
1228
1291
|
}
|
|
1229
1292
|
/**
|
|
1230
1293
|
* Default close implementation for transports. You should override this in the downstream
|
|
@@ -1429,13 +1492,17 @@ var ServerTransport = class extends Transport {
|
|
|
1429
1492
|
receivedHandshake = true;
|
|
1430
1493
|
void this.onHandshakeRequest(pendingSession, msg);
|
|
1431
1494
|
},
|
|
1432
|
-
onInvalidHandshake: (reason) => {
|
|
1495
|
+
onInvalidHandshake: (reason, code) => {
|
|
1433
1496
|
this.log?.error(
|
|
1434
1497
|
`invalid handshake: ${reason}`,
|
|
1435
1498
|
pendingSession.loggingMetadata
|
|
1436
1499
|
);
|
|
1437
1500
|
this.deletePendingSession(pendingSession);
|
|
1438
|
-
this.protocolError(
|
|
1501
|
+
this.protocolError({
|
|
1502
|
+
type: ProtocolError.HandshakeFailed,
|
|
1503
|
+
code,
|
|
1504
|
+
message: reason
|
|
1505
|
+
});
|
|
1439
1506
|
}
|
|
1440
1507
|
},
|
|
1441
1508
|
this.options,
|
|
@@ -1460,7 +1527,11 @@ var ServerTransport = class extends Transport {
|
|
|
1460
1527
|
}
|
|
1461
1528
|
})
|
|
1462
1529
|
);
|
|
1463
|
-
this.protocolError(
|
|
1530
|
+
this.protocolError({
|
|
1531
|
+
type: ProtocolError.HandshakeFailed,
|
|
1532
|
+
code,
|
|
1533
|
+
message: reason
|
|
1534
|
+
});
|
|
1464
1535
|
this.deletePendingSession(session);
|
|
1465
1536
|
}
|
|
1466
1537
|
async onHandshakeRequest(session, msg) {
|
|
@@ -1509,7 +1580,7 @@ var ServerTransport = class extends Transport {
|
|
|
1509
1580
|
let connectCase = "new session";
|
|
1510
1581
|
const clientNextExpectedSeq = msg.payload.expectedSessionState.nextExpectedSeq;
|
|
1511
1582
|
const clientNextSentSeq = msg.payload.expectedSessionState.nextSentSeq ?? 0;
|
|
1512
|
-
if (oldSession && oldSession.id === msg.payload.sessionId) {
|
|
1583
|
+
if (this.options.enableTransparentSessionReconnects && oldSession && oldSession.id === msg.payload.sessionId) {
|
|
1513
1584
|
connectCase = "transparent reconnection";
|
|
1514
1585
|
const ourNextSeq = oldSession.nextSeq();
|
|
1515
1586
|
const ourAck = oldSession.ack;
|
|
@@ -1568,10 +1639,11 @@ var ServerTransport = class extends Transport {
|
|
|
1568
1639
|
}
|
|
1569
1640
|
if (!oldSession && (clientNextSentSeq > 0 || clientNextExpectedSeq > 0)) {
|
|
1570
1641
|
connectCase = "unknown session";
|
|
1642
|
+
const rejectionMessage = this.options.enableTransparentSessionReconnects ? `client is trying to reconnect to a session the server don't know about: ${msg.payload.sessionId}` : `client is attempting a transparent reconnect to a session but the server does not support it: ${msg.payload.sessionId}`;
|
|
1571
1643
|
this.rejectHandshakeRequest(
|
|
1572
1644
|
session,
|
|
1573
1645
|
msg.from,
|
|
1574
|
-
|
|
1646
|
+
rejectionMessage,
|
|
1575
1647
|
"SESSION_STATE_MISMATCH",
|
|
1576
1648
|
{
|
|
1577
1649
|
...session.loggingMetadata,
|
|
@@ -1622,7 +1694,10 @@ var ServerTransport = class extends Transport {
|
|
|
1622
1694
|
},
|
|
1623
1695
|
onMessage: (msg2) => this.handleMsg(msg2),
|
|
1624
1696
|
onInvalidMessage: (reason) => {
|
|
1625
|
-
this.protocolError(
|
|
1697
|
+
this.protocolError({
|
|
1698
|
+
type: ProtocolError.MessageOrderingViolated,
|
|
1699
|
+
message: reason
|
|
1700
|
+
});
|
|
1626
1701
|
this.deleteSession(connectedSession);
|
|
1627
1702
|
}
|
|
1628
1703
|
}
|
|
@@ -1653,16 +1728,19 @@ var ServerTransport = class extends Transport {
|
|
|
1653
1728
|
return false;
|
|
1654
1729
|
}
|
|
1655
1730
|
const previousParsedMetadata = existingSession ? this.sessionHandshakeMetadata.get(existingSession.to) : void 0;
|
|
1656
|
-
const
|
|
1731
|
+
const parsedMetadataOrFailureCode = await this.handshakeExtensions.validate(
|
|
1657
1732
|
rawMetadata,
|
|
1658
1733
|
previousParsedMetadata
|
|
1659
1734
|
);
|
|
1660
|
-
if (import_value2.Value.Check(
|
|
1735
|
+
if (import_value2.Value.Check(
|
|
1736
|
+
HandshakeErrorCustomHandlerFatalResponseCodes,
|
|
1737
|
+
parsedMetadataOrFailureCode
|
|
1738
|
+
)) {
|
|
1661
1739
|
this.rejectHandshakeRequest(
|
|
1662
1740
|
handshakingSession,
|
|
1663
1741
|
from,
|
|
1664
1742
|
"rejected by handshake handler",
|
|
1665
|
-
|
|
1743
|
+
parsedMetadataOrFailureCode,
|
|
1666
1744
|
{
|
|
1667
1745
|
...handshakingSession.loggingMetadata,
|
|
1668
1746
|
connectedTo: from,
|
|
@@ -1671,7 +1749,7 @@ var ServerTransport = class extends Transport {
|
|
|
1671
1749
|
);
|
|
1672
1750
|
return false;
|
|
1673
1751
|
}
|
|
1674
|
-
return
|
|
1752
|
+
return parsedMetadataOrFailureCode;
|
|
1675
1753
|
}
|
|
1676
1754
|
};
|
|
1677
1755
|
|