@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
package/dist/transport/index.cjs
CHANGED
|
@@ -221,7 +221,7 @@ var import_nanoid2 = require("nanoid");
|
|
|
221
221
|
var import_api = require("@opentelemetry/api");
|
|
222
222
|
|
|
223
223
|
// package.json
|
|
224
|
-
var version = "0.23.
|
|
224
|
+
var version = "0.23.9";
|
|
225
225
|
|
|
226
226
|
// tracing/index.ts
|
|
227
227
|
function getPropagationContext(ctx) {
|
|
@@ -301,6 +301,11 @@ var Session = class {
|
|
|
301
301
|
* The active connection associated with this session
|
|
302
302
|
*/
|
|
303
303
|
connection;
|
|
304
|
+
/**
|
|
305
|
+
* A connection that is currently undergoing handshaking. Used to distinguish between the active
|
|
306
|
+
* connection, but still be able to close it if needed.
|
|
307
|
+
*/
|
|
308
|
+
handshakingConnection;
|
|
304
309
|
from;
|
|
305
310
|
to;
|
|
306
311
|
/**
|
|
@@ -480,23 +485,60 @@ var Session = class {
|
|
|
480
485
|
this.cancelGrace();
|
|
481
486
|
this.sendBufferedMessages(newConn);
|
|
482
487
|
this.connection = newConn;
|
|
488
|
+
this.handshakingConnection = void 0;
|
|
489
|
+
}
|
|
490
|
+
replaceWithNewHandshakingConnection(newConn) {
|
|
491
|
+
this.handshakingConnection = newConn;
|
|
483
492
|
}
|
|
484
493
|
beginGrace(cb) {
|
|
485
494
|
this.log?.info(
|
|
486
495
|
`starting ${this.options.sessionDisconnectGraceMs}ms grace period until session to ${this.to} is closed`,
|
|
487
496
|
this.loggingMetadata
|
|
488
497
|
);
|
|
498
|
+
this.cancelGrace({ keepHeartbeatMisses: true });
|
|
489
499
|
this.disconnectionGrace = setTimeout(() => {
|
|
490
|
-
this.
|
|
500
|
+
if (this.connection !== void 0) {
|
|
501
|
+
this.log?.warn(
|
|
502
|
+
`grace period for ${this.to} elapsed while connected. not calling callback`,
|
|
503
|
+
{
|
|
504
|
+
...this.loggingMetadata,
|
|
505
|
+
connId: this.connection.id,
|
|
506
|
+
tags: ["invariant-violation"]
|
|
507
|
+
}
|
|
508
|
+
);
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
this.log?.info(
|
|
512
|
+
`grace period for ${this.to} elapsed`,
|
|
513
|
+
this.loggingMetadata
|
|
514
|
+
);
|
|
491
515
|
cb();
|
|
492
516
|
}, this.options.sessionDisconnectGraceMs);
|
|
493
517
|
}
|
|
494
518
|
// called on reconnect of the underlying session
|
|
495
|
-
cancelGrace(
|
|
496
|
-
|
|
519
|
+
cancelGrace({ keepHeartbeatMisses } = {
|
|
520
|
+
keepHeartbeatMisses: false
|
|
521
|
+
}) {
|
|
522
|
+
if (!keepHeartbeatMisses) {
|
|
523
|
+
this.heartbeatMisses = 0;
|
|
524
|
+
}
|
|
525
|
+
if (this.disconnectionGrace === void 0)
|
|
526
|
+
return;
|
|
497
527
|
clearTimeout(this.disconnectionGrace);
|
|
498
528
|
this.disconnectionGrace = void 0;
|
|
499
529
|
}
|
|
530
|
+
/**
|
|
531
|
+
* Used to close the handshaking connection, if set.
|
|
532
|
+
*/
|
|
533
|
+
closeHandshakingConnection(expectedHandshakingConn) {
|
|
534
|
+
if (this.handshakingConnection === void 0)
|
|
535
|
+
return;
|
|
536
|
+
if (expectedHandshakingConn !== void 0 && this.handshakingConnection === expectedHandshakingConn) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
this.handshakingConnection.close();
|
|
540
|
+
this.handshakingConnection = void 0;
|
|
541
|
+
}
|
|
500
542
|
// closed when we want to discard the whole session
|
|
501
543
|
// (i.e. shutdown or session disconnect)
|
|
502
544
|
close() {
|
|
@@ -777,7 +819,13 @@ var Transport = class {
|
|
|
777
819
|
});
|
|
778
820
|
return session;
|
|
779
821
|
}
|
|
780
|
-
getOrCreateSession(
|
|
822
|
+
getOrCreateSession({
|
|
823
|
+
to,
|
|
824
|
+
conn,
|
|
825
|
+
handshakingConn,
|
|
826
|
+
sessionId,
|
|
827
|
+
propagationCtx
|
|
828
|
+
}) {
|
|
781
829
|
let session = this.sessions.get(to);
|
|
782
830
|
let isReconnect = session !== void 0;
|
|
783
831
|
if (session?.advertisedSessionId !== void 0 && sessionId !== void 0 && session.advertisedSessionId !== sessionId) {
|
|
@@ -785,7 +833,11 @@ var Transport = class {
|
|
|
785
833
|
`session for ${to} already exists but has a different session id (expected: ${session.advertisedSessionId}, got: ${sessionId}), creating a new one`,
|
|
786
834
|
session.loggingMetadata
|
|
787
835
|
);
|
|
788
|
-
this.deleteSession(
|
|
836
|
+
this.deleteSession({
|
|
837
|
+
session,
|
|
838
|
+
closeHandshakingConnection: handshakingConn !== void 0,
|
|
839
|
+
handshakingConn
|
|
840
|
+
});
|
|
789
841
|
isReconnect = false;
|
|
790
842
|
session = void 0;
|
|
791
843
|
}
|
|
@@ -799,9 +851,19 @@ var Transport = class {
|
|
|
799
851
|
if (sessionId !== void 0) {
|
|
800
852
|
session.advertisedSessionId = sessionId;
|
|
801
853
|
}
|
|
854
|
+
if (handshakingConn !== void 0) {
|
|
855
|
+
session.replaceWithNewHandshakingConnection(handshakingConn);
|
|
856
|
+
}
|
|
802
857
|
return { session, isReconnect };
|
|
803
858
|
}
|
|
804
|
-
deleteSession(
|
|
859
|
+
deleteSession({
|
|
860
|
+
session,
|
|
861
|
+
closeHandshakingConnection,
|
|
862
|
+
handshakingConn
|
|
863
|
+
}) {
|
|
864
|
+
if (closeHandshakingConnection) {
|
|
865
|
+
session.closeHandshakingConnection(handshakingConn);
|
|
866
|
+
}
|
|
805
867
|
session.close();
|
|
806
868
|
session.telemetry.span.end();
|
|
807
869
|
this.sessions.delete(session.to);
|
|
@@ -828,7 +890,11 @@ var Transport = class {
|
|
|
828
890
|
session.connection = void 0;
|
|
829
891
|
session.beginGrace(() => {
|
|
830
892
|
session.telemetry.span.addEvent("session grace period expired");
|
|
831
|
-
this.deleteSession(
|
|
893
|
+
this.deleteSession({
|
|
894
|
+
session,
|
|
895
|
+
closeHandshakingConnection: true,
|
|
896
|
+
handshakingConn: conn
|
|
897
|
+
});
|
|
832
898
|
});
|
|
833
899
|
}
|
|
834
900
|
/**
|
|
@@ -908,7 +974,7 @@ var Transport = class {
|
|
|
908
974
|
code: import_api3.SpanStatusCode.ERROR,
|
|
909
975
|
message: "message order violated"
|
|
910
976
|
});
|
|
911
|
-
|
|
977
|
+
this.deleteSession({ session, closeHandshakingConnection: true });
|
|
912
978
|
}
|
|
913
979
|
return;
|
|
914
980
|
}
|
|
@@ -962,7 +1028,7 @@ var Transport = class {
|
|
|
962
1028
|
});
|
|
963
1029
|
return void 0;
|
|
964
1030
|
}
|
|
965
|
-
return this.getOrCreateSession(to).session.send(msg);
|
|
1031
|
+
return this.getOrCreateSession({ to }).session.send(msg);
|
|
966
1032
|
}
|
|
967
1033
|
// control helpers
|
|
968
1034
|
sendCloseStream(to, streamId) {
|
|
@@ -985,7 +1051,7 @@ var Transport = class {
|
|
|
985
1051
|
close() {
|
|
986
1052
|
this.state = "closed";
|
|
987
1053
|
for (const session of this.sessions.values()) {
|
|
988
|
-
this.deleteSession(session);
|
|
1054
|
+
this.deleteSession({ session, closeHandshakingConnection: true });
|
|
989
1055
|
}
|
|
990
1056
|
this.log?.info(`manually closed transport`, { clientId: this.clientId });
|
|
991
1057
|
}
|
|
@@ -997,7 +1063,7 @@ var Transport = class {
|
|
|
997
1063
|
destroy() {
|
|
998
1064
|
this.state = "destroyed";
|
|
999
1065
|
for (const session of this.sessions.values()) {
|
|
1000
|
-
this.deleteSession(session);
|
|
1066
|
+
this.deleteSession({ session, closeHandshakingConnection: true });
|
|
1001
1067
|
}
|
|
1002
1068
|
this.log?.info(`manually destroyed transport`, { clientId: this.clientId });
|
|
1003
1069
|
}
|
|
@@ -1040,22 +1106,22 @@ var ClientTransport = class extends Transport {
|
|
|
1040
1106
|
return;
|
|
1041
1107
|
let session = void 0;
|
|
1042
1108
|
const handshakeTimeout = setTimeout(() => {
|
|
1043
|
-
if (
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1109
|
+
if (session)
|
|
1110
|
+
return;
|
|
1111
|
+
this.log?.warn(
|
|
1112
|
+
`connection to ${to} timed out waiting for handshake, closing`,
|
|
1113
|
+
{ ...conn.loggingMetadata, clientId: this.clientId, connectedTo: to }
|
|
1114
|
+
);
|
|
1115
|
+
conn.close();
|
|
1050
1116
|
}, this.options.sessionDisconnectGraceMs);
|
|
1051
1117
|
const handshakeHandler = (data) => {
|
|
1052
1118
|
const maybeSession = this.receiveHandshakeResponseMessage(data, conn);
|
|
1119
|
+
clearTimeout(handshakeTimeout);
|
|
1053
1120
|
if (!maybeSession) {
|
|
1054
1121
|
conn.close();
|
|
1055
1122
|
return;
|
|
1056
1123
|
} else {
|
|
1057
1124
|
session = maybeSession;
|
|
1058
|
-
clearTimeout(handshakeTimeout);
|
|
1059
1125
|
}
|
|
1060
1126
|
conn.removeDataListener(handshakeHandler);
|
|
1061
1127
|
conn.addDataListener((data2) => {
|
|
@@ -1162,11 +1228,11 @@ var ClientTransport = class extends Transport {
|
|
|
1162
1228
|
connectedTo: parsed.from,
|
|
1163
1229
|
transportMessage: parsed
|
|
1164
1230
|
});
|
|
1165
|
-
const { session, isReconnect } = this.getOrCreateSession(
|
|
1166
|
-
parsed.from,
|
|
1231
|
+
const { session, isReconnect } = this.getOrCreateSession({
|
|
1232
|
+
to: parsed.from,
|
|
1167
1233
|
conn,
|
|
1168
|
-
parsed.payload.status.sessionId
|
|
1169
|
-
);
|
|
1234
|
+
sessionId: parsed.payload.status.sessionId
|
|
1235
|
+
});
|
|
1170
1236
|
this.onConnect(conn, parsed.from, session, isReconnect);
|
|
1171
1237
|
this.retryBudget.startRestoringBudget(parsed.from);
|
|
1172
1238
|
return session;
|
|
@@ -1272,9 +1338,17 @@ var ClientTransport = class extends Transport {
|
|
|
1272
1338
|
}
|
|
1273
1339
|
}
|
|
1274
1340
|
}
|
|
1275
|
-
deleteSession(
|
|
1341
|
+
deleteSession({
|
|
1342
|
+
session,
|
|
1343
|
+
closeHandshakingConnection,
|
|
1344
|
+
handshakingConn
|
|
1345
|
+
}) {
|
|
1276
1346
|
this.inflightConnectionPromises.delete(session.to);
|
|
1277
|
-
super.deleteSession(
|
|
1347
|
+
super.deleteSession({
|
|
1348
|
+
session,
|
|
1349
|
+
closeHandshakingConnection,
|
|
1350
|
+
handshakingConn
|
|
1351
|
+
});
|
|
1278
1352
|
}
|
|
1279
1353
|
async sendHandshake(to, conn) {
|
|
1280
1354
|
let metadata = void 0;
|
|
@@ -1301,7 +1375,7 @@ var ClientTransport = class extends Transport {
|
|
|
1301
1375
|
return false;
|
|
1302
1376
|
}
|
|
1303
1377
|
}
|
|
1304
|
-
const { session } = this.getOrCreateSession(to);
|
|
1378
|
+
const { session } = this.getOrCreateSession({ to, handshakingConn: conn });
|
|
1305
1379
|
const requestMsg = handshakeRequestMessage(
|
|
1306
1380
|
this.clientId,
|
|
1307
1381
|
to,
|
|
@@ -1552,12 +1626,12 @@ var ServerTransport = class extends Transport {
|
|
|
1552
1626
|
if (parsedMetadata === false) {
|
|
1553
1627
|
return false;
|
|
1554
1628
|
}
|
|
1555
|
-
const { session, isReconnect } = this.getOrCreateSession(
|
|
1556
|
-
parsed.from,
|
|
1629
|
+
const { session, isReconnect } = this.getOrCreateSession({
|
|
1630
|
+
to: parsed.from,
|
|
1557
1631
|
conn,
|
|
1558
|
-
parsed.payload.sessionId,
|
|
1559
|
-
parsed.tracing
|
|
1560
|
-
);
|
|
1632
|
+
sessionId: parsed.payload.sessionId,
|
|
1633
|
+
propagationCtx: parsed.tracing
|
|
1634
|
+
});
|
|
1561
1635
|
this.sessionHandshakeMetadata.set(session, parsedMetadata);
|
|
1562
1636
|
this.log?.debug(
|
|
1563
1637
|
`handshake from ${parsed.from} ok, responding with handshake success`,
|