@replit/river 0.23.7 → 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-RLVU5DRX.js → chunk-KIWWKSRI.js} +2 -2
- package/dist/{chunk-M3TGXFWT.js → chunk-U4CSF3SQ.js} +2 -2
- package/dist/chunk-U4CSF3SQ.js.map +1 -0
- package/dist/{chunk-2KC75LS4.js → chunk-XKVIPKMR.js} +2 -3
- package/dist/chunk-XKVIPKMR.js.map +1 -0
- package/dist/{chunk-MFF6IPBA.js → chunk-XUVTMFTJ.js} +2 -2
- package/dist/{chunk-MFF6IPBA.js.map → chunk-XUVTMFTJ.js.map} +1 -1
- package/dist/{chunk-XYFXRL7Q.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 -28
- 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 -18
- 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/dist/util/testHelpers.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2KC75LS4.js.map +0 -1
- package/dist/chunk-M3TGXFWT.js.map +0 -1
- package/dist/chunk-XYFXRL7Q.js.map +0 -1
- /package/dist/{chunk-RLVU5DRX.js.map → chunk-KIWWKSRI.js.map} +0 -0
|
@@ -196,7 +196,7 @@ var import_nanoid2 = require("nanoid");
|
|
|
196
196
|
var import_api = require("@opentelemetry/api");
|
|
197
197
|
|
|
198
198
|
// package.json
|
|
199
|
-
var version = "0.23.
|
|
199
|
+
var version = "0.23.9";
|
|
200
200
|
|
|
201
201
|
// tracing/index.ts
|
|
202
202
|
function createSessionTelemetryInfo(session, propagationCtx) {
|
|
@@ -267,6 +267,11 @@ var Session = class {
|
|
|
267
267
|
* The active connection associated with this session
|
|
268
268
|
*/
|
|
269
269
|
connection;
|
|
270
|
+
/**
|
|
271
|
+
* A connection that is currently undergoing handshaking. Used to distinguish between the active
|
|
272
|
+
* connection, but still be able to close it if needed.
|
|
273
|
+
*/
|
|
274
|
+
handshakingConnection;
|
|
270
275
|
from;
|
|
271
276
|
to;
|
|
272
277
|
/**
|
|
@@ -446,23 +451,60 @@ var Session = class {
|
|
|
446
451
|
this.cancelGrace();
|
|
447
452
|
this.sendBufferedMessages(newConn);
|
|
448
453
|
this.connection = newConn;
|
|
454
|
+
this.handshakingConnection = void 0;
|
|
455
|
+
}
|
|
456
|
+
replaceWithNewHandshakingConnection(newConn) {
|
|
457
|
+
this.handshakingConnection = newConn;
|
|
449
458
|
}
|
|
450
459
|
beginGrace(cb) {
|
|
451
460
|
this.log?.info(
|
|
452
461
|
`starting ${this.options.sessionDisconnectGraceMs}ms grace period until session to ${this.to} is closed`,
|
|
453
462
|
this.loggingMetadata
|
|
454
463
|
);
|
|
464
|
+
this.cancelGrace({ keepHeartbeatMisses: true });
|
|
455
465
|
this.disconnectionGrace = setTimeout(() => {
|
|
456
|
-
this.
|
|
466
|
+
if (this.connection !== void 0) {
|
|
467
|
+
this.log?.warn(
|
|
468
|
+
`grace period for ${this.to} elapsed while connected. not calling callback`,
|
|
469
|
+
{
|
|
470
|
+
...this.loggingMetadata,
|
|
471
|
+
connId: this.connection.id,
|
|
472
|
+
tags: ["invariant-violation"]
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
this.log?.info(
|
|
478
|
+
`grace period for ${this.to} elapsed`,
|
|
479
|
+
this.loggingMetadata
|
|
480
|
+
);
|
|
457
481
|
cb();
|
|
458
482
|
}, this.options.sessionDisconnectGraceMs);
|
|
459
483
|
}
|
|
460
484
|
// called on reconnect of the underlying session
|
|
461
|
-
cancelGrace(
|
|
462
|
-
|
|
485
|
+
cancelGrace({ keepHeartbeatMisses } = {
|
|
486
|
+
keepHeartbeatMisses: false
|
|
487
|
+
}) {
|
|
488
|
+
if (!keepHeartbeatMisses) {
|
|
489
|
+
this.heartbeatMisses = 0;
|
|
490
|
+
}
|
|
491
|
+
if (this.disconnectionGrace === void 0)
|
|
492
|
+
return;
|
|
463
493
|
clearTimeout(this.disconnectionGrace);
|
|
464
494
|
this.disconnectionGrace = void 0;
|
|
465
495
|
}
|
|
496
|
+
/**
|
|
497
|
+
* Used to close the handshaking connection, if set.
|
|
498
|
+
*/
|
|
499
|
+
closeHandshakingConnection(expectedHandshakingConn) {
|
|
500
|
+
if (this.handshakingConnection === void 0)
|
|
501
|
+
return;
|
|
502
|
+
if (expectedHandshakingConn !== void 0 && this.handshakingConnection === expectedHandshakingConn) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
this.handshakingConnection.close();
|
|
506
|
+
this.handshakingConnection = void 0;
|
|
507
|
+
}
|
|
466
508
|
// closed when we want to discard the whole session
|
|
467
509
|
// (i.e. shutdown or session disconnect)
|
|
468
510
|
close() {
|
|
@@ -672,7 +714,13 @@ var Transport = class {
|
|
|
672
714
|
});
|
|
673
715
|
return session;
|
|
674
716
|
}
|
|
675
|
-
getOrCreateSession(
|
|
717
|
+
getOrCreateSession({
|
|
718
|
+
to,
|
|
719
|
+
conn,
|
|
720
|
+
handshakingConn,
|
|
721
|
+
sessionId,
|
|
722
|
+
propagationCtx
|
|
723
|
+
}) {
|
|
676
724
|
let session = this.sessions.get(to);
|
|
677
725
|
let isReconnect = session !== void 0;
|
|
678
726
|
if (session?.advertisedSessionId !== void 0 && sessionId !== void 0 && session.advertisedSessionId !== sessionId) {
|
|
@@ -680,7 +728,11 @@ var Transport = class {
|
|
|
680
728
|
`session for ${to} already exists but has a different session id (expected: ${session.advertisedSessionId}, got: ${sessionId}), creating a new one`,
|
|
681
729
|
session.loggingMetadata
|
|
682
730
|
);
|
|
683
|
-
this.deleteSession(
|
|
731
|
+
this.deleteSession({
|
|
732
|
+
session,
|
|
733
|
+
closeHandshakingConnection: handshakingConn !== void 0,
|
|
734
|
+
handshakingConn
|
|
735
|
+
});
|
|
684
736
|
isReconnect = false;
|
|
685
737
|
session = void 0;
|
|
686
738
|
}
|
|
@@ -694,9 +746,19 @@ var Transport = class {
|
|
|
694
746
|
if (sessionId !== void 0) {
|
|
695
747
|
session.advertisedSessionId = sessionId;
|
|
696
748
|
}
|
|
749
|
+
if (handshakingConn !== void 0) {
|
|
750
|
+
session.replaceWithNewHandshakingConnection(handshakingConn);
|
|
751
|
+
}
|
|
697
752
|
return { session, isReconnect };
|
|
698
753
|
}
|
|
699
|
-
deleteSession(
|
|
754
|
+
deleteSession({
|
|
755
|
+
session,
|
|
756
|
+
closeHandshakingConnection,
|
|
757
|
+
handshakingConn
|
|
758
|
+
}) {
|
|
759
|
+
if (closeHandshakingConnection) {
|
|
760
|
+
session.closeHandshakingConnection(handshakingConn);
|
|
761
|
+
}
|
|
700
762
|
session.close();
|
|
701
763
|
session.telemetry.span.end();
|
|
702
764
|
this.sessions.delete(session.to);
|
|
@@ -723,7 +785,11 @@ var Transport = class {
|
|
|
723
785
|
session.connection = void 0;
|
|
724
786
|
session.beginGrace(() => {
|
|
725
787
|
session.telemetry.span.addEvent("session grace period expired");
|
|
726
|
-
this.deleteSession(
|
|
788
|
+
this.deleteSession({
|
|
789
|
+
session,
|
|
790
|
+
closeHandshakingConnection: true,
|
|
791
|
+
handshakingConn: conn
|
|
792
|
+
});
|
|
727
793
|
});
|
|
728
794
|
}
|
|
729
795
|
/**
|
|
@@ -803,7 +869,7 @@ var Transport = class {
|
|
|
803
869
|
code: import_api3.SpanStatusCode.ERROR,
|
|
804
870
|
message: "message order violated"
|
|
805
871
|
});
|
|
806
|
-
|
|
872
|
+
this.deleteSession({ session, closeHandshakingConnection: true });
|
|
807
873
|
}
|
|
808
874
|
return;
|
|
809
875
|
}
|
|
@@ -857,7 +923,7 @@ var Transport = class {
|
|
|
857
923
|
});
|
|
858
924
|
return void 0;
|
|
859
925
|
}
|
|
860
|
-
return this.getOrCreateSession(to).session.send(msg);
|
|
926
|
+
return this.getOrCreateSession({ to }).session.send(msg);
|
|
861
927
|
}
|
|
862
928
|
// control helpers
|
|
863
929
|
sendCloseStream(to, streamId) {
|
|
@@ -880,7 +946,7 @@ var Transport = class {
|
|
|
880
946
|
close() {
|
|
881
947
|
this.state = "closed";
|
|
882
948
|
for (const session of this.sessions.values()) {
|
|
883
|
-
this.deleteSession(session);
|
|
949
|
+
this.deleteSession({ session, closeHandshakingConnection: true });
|
|
884
950
|
}
|
|
885
951
|
this.log?.info(`manually closed transport`, { clientId: this.clientId });
|
|
886
952
|
}
|
|
@@ -892,7 +958,7 @@ var Transport = class {
|
|
|
892
958
|
destroy() {
|
|
893
959
|
this.state = "destroyed";
|
|
894
960
|
for (const session of this.sessions.values()) {
|
|
895
|
-
this.deleteSession(session);
|
|
961
|
+
this.deleteSession({ session, closeHandshakingConnection: true });
|
|
896
962
|
}
|
|
897
963
|
this.log?.info(`manually destroyed transport`, { clientId: this.clientId });
|
|
898
964
|
}
|
|
@@ -1126,12 +1192,12 @@ var ServerTransport = class extends Transport {
|
|
|
1126
1192
|
if (parsedMetadata === false) {
|
|
1127
1193
|
return false;
|
|
1128
1194
|
}
|
|
1129
|
-
const { session, isReconnect } = this.getOrCreateSession(
|
|
1130
|
-
parsed.from,
|
|
1195
|
+
const { session, isReconnect } = this.getOrCreateSession({
|
|
1196
|
+
to: parsed.from,
|
|
1131
1197
|
conn,
|
|
1132
|
-
parsed.payload.sessionId,
|
|
1133
|
-
parsed.tracing
|
|
1134
|
-
);
|
|
1198
|
+
sessionId: parsed.payload.sessionId,
|
|
1199
|
+
propagationCtx: parsed.tracing
|
|
1200
|
+
});
|
|
1135
1201
|
this.sessionHandshakeMetadata.set(session, parsedMetadata);
|
|
1136
1202
|
this.log?.debug(
|
|
1137
1203
|
`handshake from ${parsed.from} ok, responding with handshake success`,
|
|
@@ -1167,7 +1233,6 @@ var WebSocketConnection = class extends Connection {
|
|
|
1167
1233
|
`websocket closed with code and reason: ${code} - ${reason}`
|
|
1168
1234
|
)
|
|
1169
1235
|
);
|
|
1170
|
-
return;
|
|
1171
1236
|
}
|
|
1172
1237
|
if (this.closeCb) {
|
|
1173
1238
|
this.closeCb();
|