@replit/river 0.23.8 → 0.23.9
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-DXTG3E3B.js → chunk-KIWWKSRI.js} +2 -2
- package/dist/{chunk-WQRQFAP6.js → chunk-U4CSF3SQ.js} +2 -2
- package/dist/chunk-U4CSF3SQ.js.map +1 -0
- package/dist/{chunk-CBNCT4B3.js → chunk-XKVIPKMR.js} +2 -2
- package/dist/{chunk-ELZRZNA5.js → chunk-XUVTMFTJ.js} +2 -2
- package/dist/{chunk-ELZRZNA5.js.map → chunk-XUVTMFTJ.js.map} +1 -1
- package/dist/{chunk-RJ6CXPBM.js → chunk-YGW5PYGV.js} +107 -33
- package/dist/chunk-YGW5PYGV.js.map +1 -0
- package/dist/{connection-6ce35bd5.d.ts → connection-afa08cf1.d.ts} +1 -1
- package/dist/{connection-a3fdfa3a.d.ts → connection-f5fb7805.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 +5 -5
- package/dist/router/index.d.ts +5 -5
- package/dist/router/index.js +2 -2
- package/dist/{services-fd8a9894.d.ts → services-49b1b43d.d.ts} +10 -9
- package/dist/transport/impls/uds/client.cjs +101 -27
- package/dist/transport/impls/uds/client.cjs.map +1 -1
- package/dist/transport/impls/uds/client.d.cts +2 -2
- package/dist/transport/impls/uds/client.d.ts +2 -2
- package/dist/transport/impls/uds/client.js +3 -3
- package/dist/transport/impls/uds/server.cjs +83 -17
- package/dist/transport/impls/uds/server.cjs.map +1 -1
- package/dist/transport/impls/uds/server.d.cts +2 -2
- package/dist/transport/impls/uds/server.d.ts +2 -2
- package/dist/transport/impls/uds/server.js +3 -3
- package/dist/transport/impls/ws/client.cjs +101 -27
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +2 -2
- package/dist/transport/impls/ws/client.d.ts +2 -2
- package/dist/transport/impls/ws/client.js +3 -3
- package/dist/transport/impls/ws/server.cjs +83 -17
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +2 -2
- package/dist/transport/impls/ws/server.d.ts +2 -2
- package/dist/transport/impls/ws/server.js +3 -3
- package/dist/transport/index.cjs +106 -32
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +1 -1
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +2 -2
- package/dist/{transport-3d34f714.d.ts → transport-3d0ba1da.d.ts} +33 -7
- package/dist/util/testHelpers.cjs +46 -4
- package/dist/util/testHelpers.cjs.map +1 -1
- package/dist/util/testHelpers.d.cts +2 -2
- package/dist/util/testHelpers.d.ts +2 -2
- package/dist/util/testHelpers.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-RJ6CXPBM.js.map +0 -1
- package/dist/chunk-WQRQFAP6.js.map +0 -1
- /package/dist/{chunk-DXTG3E3B.js.map → chunk-KIWWKSRI.js.map} +0 -0
- /package/dist/{chunk-CBNCT4B3.js.map → chunk-XKVIPKMR.js.map} +0 -0
|
@@ -199,7 +199,7 @@ var import_nanoid2 = require("nanoid");
|
|
|
199
199
|
var import_api = require("@opentelemetry/api");
|
|
200
200
|
|
|
201
201
|
// package.json
|
|
202
|
-
var version = "0.23.
|
|
202
|
+
var version = "0.23.9";
|
|
203
203
|
|
|
204
204
|
// tracing/index.ts
|
|
205
205
|
function getPropagationContext(ctx) {
|
|
@@ -279,6 +279,11 @@ var Session = class {
|
|
|
279
279
|
* The active connection associated with this session
|
|
280
280
|
*/
|
|
281
281
|
connection;
|
|
282
|
+
/**
|
|
283
|
+
* A connection that is currently undergoing handshaking. Used to distinguish between the active
|
|
284
|
+
* connection, but still be able to close it if needed.
|
|
285
|
+
*/
|
|
286
|
+
handshakingConnection;
|
|
282
287
|
from;
|
|
283
288
|
to;
|
|
284
289
|
/**
|
|
@@ -458,23 +463,60 @@ var Session = class {
|
|
|
458
463
|
this.cancelGrace();
|
|
459
464
|
this.sendBufferedMessages(newConn);
|
|
460
465
|
this.connection = newConn;
|
|
466
|
+
this.handshakingConnection = void 0;
|
|
467
|
+
}
|
|
468
|
+
replaceWithNewHandshakingConnection(newConn) {
|
|
469
|
+
this.handshakingConnection = newConn;
|
|
461
470
|
}
|
|
462
471
|
beginGrace(cb) {
|
|
463
472
|
this.log?.info(
|
|
464
473
|
`starting ${this.options.sessionDisconnectGraceMs}ms grace period until session to ${this.to} is closed`,
|
|
465
474
|
this.loggingMetadata
|
|
466
475
|
);
|
|
476
|
+
this.cancelGrace({ keepHeartbeatMisses: true });
|
|
467
477
|
this.disconnectionGrace = setTimeout(() => {
|
|
468
|
-
this.
|
|
478
|
+
if (this.connection !== void 0) {
|
|
479
|
+
this.log?.warn(
|
|
480
|
+
`grace period for ${this.to} elapsed while connected. not calling callback`,
|
|
481
|
+
{
|
|
482
|
+
...this.loggingMetadata,
|
|
483
|
+
connId: this.connection.id,
|
|
484
|
+
tags: ["invariant-violation"]
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
this.log?.info(
|
|
490
|
+
`grace period for ${this.to} elapsed`,
|
|
491
|
+
this.loggingMetadata
|
|
492
|
+
);
|
|
469
493
|
cb();
|
|
470
494
|
}, this.options.sessionDisconnectGraceMs);
|
|
471
495
|
}
|
|
472
496
|
// called on reconnect of the underlying session
|
|
473
|
-
cancelGrace(
|
|
474
|
-
|
|
497
|
+
cancelGrace({ keepHeartbeatMisses } = {
|
|
498
|
+
keepHeartbeatMisses: false
|
|
499
|
+
}) {
|
|
500
|
+
if (!keepHeartbeatMisses) {
|
|
501
|
+
this.heartbeatMisses = 0;
|
|
502
|
+
}
|
|
503
|
+
if (this.disconnectionGrace === void 0)
|
|
504
|
+
return;
|
|
475
505
|
clearTimeout(this.disconnectionGrace);
|
|
476
506
|
this.disconnectionGrace = void 0;
|
|
477
507
|
}
|
|
508
|
+
/**
|
|
509
|
+
* Used to close the handshaking connection, if set.
|
|
510
|
+
*/
|
|
511
|
+
closeHandshakingConnection(expectedHandshakingConn) {
|
|
512
|
+
if (this.handshakingConnection === void 0)
|
|
513
|
+
return;
|
|
514
|
+
if (expectedHandshakingConn !== void 0 && this.handshakingConnection === expectedHandshakingConn) {
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
this.handshakingConnection.close();
|
|
518
|
+
this.handshakingConnection = void 0;
|
|
519
|
+
}
|
|
478
520
|
// closed when we want to discard the whole session
|
|
479
521
|
// (i.e. shutdown or session disconnect)
|
|
480
522
|
close() {
|
|
@@ -755,7 +797,13 @@ var Transport = class {
|
|
|
755
797
|
});
|
|
756
798
|
return session;
|
|
757
799
|
}
|
|
758
|
-
getOrCreateSession(
|
|
800
|
+
getOrCreateSession({
|
|
801
|
+
to,
|
|
802
|
+
conn,
|
|
803
|
+
handshakingConn,
|
|
804
|
+
sessionId,
|
|
805
|
+
propagationCtx
|
|
806
|
+
}) {
|
|
759
807
|
let session = this.sessions.get(to);
|
|
760
808
|
let isReconnect = session !== void 0;
|
|
761
809
|
if (session?.advertisedSessionId !== void 0 && sessionId !== void 0 && session.advertisedSessionId !== sessionId) {
|
|
@@ -763,7 +811,11 @@ var Transport = class {
|
|
|
763
811
|
`session for ${to} already exists but has a different session id (expected: ${session.advertisedSessionId}, got: ${sessionId}), creating a new one`,
|
|
764
812
|
session.loggingMetadata
|
|
765
813
|
);
|
|
766
|
-
this.deleteSession(
|
|
814
|
+
this.deleteSession({
|
|
815
|
+
session,
|
|
816
|
+
closeHandshakingConnection: handshakingConn !== void 0,
|
|
817
|
+
handshakingConn
|
|
818
|
+
});
|
|
767
819
|
isReconnect = false;
|
|
768
820
|
session = void 0;
|
|
769
821
|
}
|
|
@@ -777,9 +829,19 @@ var Transport = class {
|
|
|
777
829
|
if (sessionId !== void 0) {
|
|
778
830
|
session.advertisedSessionId = sessionId;
|
|
779
831
|
}
|
|
832
|
+
if (handshakingConn !== void 0) {
|
|
833
|
+
session.replaceWithNewHandshakingConnection(handshakingConn);
|
|
834
|
+
}
|
|
780
835
|
return { session, isReconnect };
|
|
781
836
|
}
|
|
782
|
-
deleteSession(
|
|
837
|
+
deleteSession({
|
|
838
|
+
session,
|
|
839
|
+
closeHandshakingConnection,
|
|
840
|
+
handshakingConn
|
|
841
|
+
}) {
|
|
842
|
+
if (closeHandshakingConnection) {
|
|
843
|
+
session.closeHandshakingConnection(handshakingConn);
|
|
844
|
+
}
|
|
783
845
|
session.close();
|
|
784
846
|
session.telemetry.span.end();
|
|
785
847
|
this.sessions.delete(session.to);
|
|
@@ -806,7 +868,11 @@ var Transport = class {
|
|
|
806
868
|
session.connection = void 0;
|
|
807
869
|
session.beginGrace(() => {
|
|
808
870
|
session.telemetry.span.addEvent("session grace period expired");
|
|
809
|
-
this.deleteSession(
|
|
871
|
+
this.deleteSession({
|
|
872
|
+
session,
|
|
873
|
+
closeHandshakingConnection: true,
|
|
874
|
+
handshakingConn: conn
|
|
875
|
+
});
|
|
810
876
|
});
|
|
811
877
|
}
|
|
812
878
|
/**
|
|
@@ -886,7 +952,7 @@ var Transport = class {
|
|
|
886
952
|
code: import_api3.SpanStatusCode.ERROR,
|
|
887
953
|
message: "message order violated"
|
|
888
954
|
});
|
|
889
|
-
|
|
955
|
+
this.deleteSession({ session, closeHandshakingConnection: true });
|
|
890
956
|
}
|
|
891
957
|
return;
|
|
892
958
|
}
|
|
@@ -940,7 +1006,7 @@ var Transport = class {
|
|
|
940
1006
|
});
|
|
941
1007
|
return void 0;
|
|
942
1008
|
}
|
|
943
|
-
return this.getOrCreateSession(to).session.send(msg);
|
|
1009
|
+
return this.getOrCreateSession({ to }).session.send(msg);
|
|
944
1010
|
}
|
|
945
1011
|
// control helpers
|
|
946
1012
|
sendCloseStream(to, streamId) {
|
|
@@ -963,7 +1029,7 @@ var Transport = class {
|
|
|
963
1029
|
close() {
|
|
964
1030
|
this.state = "closed";
|
|
965
1031
|
for (const session of this.sessions.values()) {
|
|
966
|
-
this.deleteSession(session);
|
|
1032
|
+
this.deleteSession({ session, closeHandshakingConnection: true });
|
|
967
1033
|
}
|
|
968
1034
|
this.log?.info(`manually closed transport`, { clientId: this.clientId });
|
|
969
1035
|
}
|
|
@@ -975,7 +1041,7 @@ var Transport = class {
|
|
|
975
1041
|
destroy() {
|
|
976
1042
|
this.state = "destroyed";
|
|
977
1043
|
for (const session of this.sessions.values()) {
|
|
978
|
-
this.deleteSession(session);
|
|
1044
|
+
this.deleteSession({ session, closeHandshakingConnection: true });
|
|
979
1045
|
}
|
|
980
1046
|
this.log?.info(`manually destroyed transport`, { clientId: this.clientId });
|
|
981
1047
|
}
|
|
@@ -1018,22 +1084,22 @@ var ClientTransport = class extends Transport {
|
|
|
1018
1084
|
return;
|
|
1019
1085
|
let session = void 0;
|
|
1020
1086
|
const handshakeTimeout = setTimeout(() => {
|
|
1021
|
-
if (
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1087
|
+
if (session)
|
|
1088
|
+
return;
|
|
1089
|
+
this.log?.warn(
|
|
1090
|
+
`connection to ${to} timed out waiting for handshake, closing`,
|
|
1091
|
+
{ ...conn.loggingMetadata, clientId: this.clientId, connectedTo: to }
|
|
1092
|
+
);
|
|
1093
|
+
conn.close();
|
|
1028
1094
|
}, this.options.sessionDisconnectGraceMs);
|
|
1029
1095
|
const handshakeHandler = (data) => {
|
|
1030
1096
|
const maybeSession = this.receiveHandshakeResponseMessage(data, conn);
|
|
1097
|
+
clearTimeout(handshakeTimeout);
|
|
1031
1098
|
if (!maybeSession) {
|
|
1032
1099
|
conn.close();
|
|
1033
1100
|
return;
|
|
1034
1101
|
} else {
|
|
1035
1102
|
session = maybeSession;
|
|
1036
|
-
clearTimeout(handshakeTimeout);
|
|
1037
1103
|
}
|
|
1038
1104
|
conn.removeDataListener(handshakeHandler);
|
|
1039
1105
|
conn.addDataListener((data2) => {
|
|
@@ -1140,11 +1206,11 @@ var ClientTransport = class extends Transport {
|
|
|
1140
1206
|
connectedTo: parsed.from,
|
|
1141
1207
|
transportMessage: parsed
|
|
1142
1208
|
});
|
|
1143
|
-
const { session, isReconnect } = this.getOrCreateSession(
|
|
1144
|
-
parsed.from,
|
|
1209
|
+
const { session, isReconnect } = this.getOrCreateSession({
|
|
1210
|
+
to: parsed.from,
|
|
1145
1211
|
conn,
|
|
1146
|
-
parsed.payload.status.sessionId
|
|
1147
|
-
);
|
|
1212
|
+
sessionId: parsed.payload.status.sessionId
|
|
1213
|
+
});
|
|
1148
1214
|
this.onConnect(conn, parsed.from, session, isReconnect);
|
|
1149
1215
|
this.retryBudget.startRestoringBudget(parsed.from);
|
|
1150
1216
|
return session;
|
|
@@ -1250,9 +1316,17 @@ var ClientTransport = class extends Transport {
|
|
|
1250
1316
|
}
|
|
1251
1317
|
}
|
|
1252
1318
|
}
|
|
1253
|
-
deleteSession(
|
|
1319
|
+
deleteSession({
|
|
1320
|
+
session,
|
|
1321
|
+
closeHandshakingConnection,
|
|
1322
|
+
handshakingConn
|
|
1323
|
+
}) {
|
|
1254
1324
|
this.inflightConnectionPromises.delete(session.to);
|
|
1255
|
-
super.deleteSession(
|
|
1325
|
+
super.deleteSession({
|
|
1326
|
+
session,
|
|
1327
|
+
closeHandshakingConnection,
|
|
1328
|
+
handshakingConn
|
|
1329
|
+
});
|
|
1256
1330
|
}
|
|
1257
1331
|
async sendHandshake(to, conn) {
|
|
1258
1332
|
let metadata = void 0;
|
|
@@ -1279,7 +1353,7 @@ var ClientTransport = class extends Transport {
|
|
|
1279
1353
|
return false;
|
|
1280
1354
|
}
|
|
1281
1355
|
}
|
|
1282
|
-
const { session } = this.getOrCreateSession(to);
|
|
1356
|
+
const { session } = this.getOrCreateSession({ to, handshakingConn: conn });
|
|
1283
1357
|
const requestMsg = handshakeRequestMessage(
|
|
1284
1358
|
this.clientId,
|
|
1285
1359
|
to,
|