@replit/river 0.23.10 → 0.23.12
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-FRICSBDW.js → chunk-7RUKEUKE.js} +2 -2
- package/dist/{chunk-FRICSBDW.js.map → chunk-7RUKEUKE.js.map} +1 -1
- package/dist/{chunk-UXQMGZKP.js → chunk-H6KTH6W6.js} +2 -2
- package/dist/{chunk-Z4G27Y2I.js → chunk-HDBVL7EF.js} +2 -2
- package/dist/{chunk-KBAZ5TWE.js → chunk-VRU4IKRT.js} +62 -50
- package/dist/chunk-VRU4IKRT.js.map +1 -0
- package/dist/{chunk-B323CECK.js → chunk-XZ6IOBM5.js} +9 -9
- package/dist/chunk-XZ6IOBM5.js.map +1 -0
- package/dist/{connection-efcd4e1a.d.ts → connection-581558f8.d.ts} +1 -1
- package/dist/{connection-700340c4.d.ts → connection-8debd45f.d.ts} +1 -1
- package/dist/router/index.cjs +8 -8
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +11 -7
- package/dist/router/index.d.ts +11 -7
- package/dist/router/index.js +2 -2
- package/dist/{services-409c5545.d.ts → services-ca72c9f8.d.ts} +1 -1
- package/dist/transport/impls/uds/client.cjs +59 -47
- 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 +20 -38
- 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 +59 -47
- 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 +20 -38
- 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 +61 -49
- 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-cf856c41.d.ts → transport-47af1c81.d.ts} +4 -5
- package/dist/util/testHelpers.cjs +8 -23
- 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-B323CECK.js.map +0 -1
- package/dist/chunk-KBAZ5TWE.js.map +0 -1
- /package/dist/{chunk-UXQMGZKP.js.map → chunk-H6KTH6W6.js.map} +0 -0
- /package/dist/{chunk-Z4G27Y2I.js.map → chunk-HDBVL7EF.js.map} +0 -0
package/dist/transport/index.cjs
CHANGED
|
@@ -224,7 +224,7 @@ var import_nanoid2 = require("nanoid");
|
|
|
224
224
|
var import_api = require("@opentelemetry/api");
|
|
225
225
|
|
|
226
226
|
// package.json
|
|
227
|
-
var version = "0.23.
|
|
227
|
+
var version = "0.23.12";
|
|
228
228
|
|
|
229
229
|
// tracing/index.ts
|
|
230
230
|
function getPropagationContext(ctx) {
|
|
@@ -483,10 +483,12 @@ var Session = class {
|
|
|
483
483
|
this.connection.close();
|
|
484
484
|
this.connection = void 0;
|
|
485
485
|
}
|
|
486
|
-
replaceWithNewConnection(newConn) {
|
|
486
|
+
replaceWithNewConnection(newConn, isTransparentReconnect) {
|
|
487
487
|
this.closeStaleConnection(newConn);
|
|
488
488
|
this.cancelGrace();
|
|
489
|
-
|
|
489
|
+
if (isTransparentReconnect) {
|
|
490
|
+
this.sendBufferedMessages(newConn);
|
|
491
|
+
}
|
|
490
492
|
this.connection = newConn;
|
|
491
493
|
this.handshakingConnection = void 0;
|
|
492
494
|
}
|
|
@@ -498,19 +500,8 @@ var Session = class {
|
|
|
498
500
|
`starting ${this.options.sessionDisconnectGraceMs}ms grace period until session to ${this.to} is closed`,
|
|
499
501
|
this.loggingMetadata
|
|
500
502
|
);
|
|
501
|
-
this.cancelGrace(
|
|
503
|
+
this.cancelGrace();
|
|
502
504
|
this.disconnectionGrace = setTimeout(() => {
|
|
503
|
-
if (this.connection !== void 0) {
|
|
504
|
-
this.log?.warn(
|
|
505
|
-
`grace period for ${this.to} elapsed while connected. not calling callback`,
|
|
506
|
-
{
|
|
507
|
-
...this.loggingMetadata,
|
|
508
|
-
connId: this.connection.id,
|
|
509
|
-
tags: ["invariant-violation"]
|
|
510
|
-
}
|
|
511
|
-
);
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
505
|
this.log?.info(
|
|
515
506
|
`grace period for ${this.to} elapsed`,
|
|
516
507
|
this.loggingMetadata
|
|
@@ -519,14 +510,8 @@ var Session = class {
|
|
|
519
510
|
}, this.options.sessionDisconnectGraceMs);
|
|
520
511
|
}
|
|
521
512
|
// called on reconnect of the underlying session
|
|
522
|
-
cancelGrace(
|
|
523
|
-
|
|
524
|
-
}) {
|
|
525
|
-
if (!keepHeartbeatMisses) {
|
|
526
|
-
this.heartbeatMisses = 0;
|
|
527
|
-
}
|
|
528
|
-
if (this.disconnectionGrace === void 0)
|
|
529
|
-
return;
|
|
513
|
+
cancelGrace() {
|
|
514
|
+
this.heartbeatMisses = 0;
|
|
530
515
|
clearTimeout(this.disconnectionGrace);
|
|
531
516
|
this.disconnectionGrace = void 0;
|
|
532
517
|
}
|
|
@@ -787,21 +772,17 @@ var Transport = class {
|
|
|
787
772
|
* and we know the identity of the connected client.
|
|
788
773
|
* @param conn The connection object.
|
|
789
774
|
*/
|
|
790
|
-
onConnect(conn,
|
|
775
|
+
onConnect(conn, session, isTransparentReconnect) {
|
|
791
776
|
this.eventDispatcher.dispatchEvent("connectionStatus", {
|
|
792
777
|
status: "connect",
|
|
793
778
|
conn
|
|
794
779
|
});
|
|
795
780
|
conn.telemetry = createConnectionTelemetryInfo(conn, session.telemetry);
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
clientId: this.clientId,
|
|
802
|
-
connectedTo
|
|
803
|
-
});
|
|
804
|
-
}
|
|
781
|
+
session.replaceWithNewConnection(conn, isTransparentReconnect);
|
|
782
|
+
this.log?.info(`connected to ${session.to}`, {
|
|
783
|
+
...conn.loggingMetadata,
|
|
784
|
+
...session.loggingMetadata
|
|
785
|
+
});
|
|
805
786
|
}
|
|
806
787
|
createSession(to, conn, propagationCtx) {
|
|
807
788
|
const session = new Session(
|
|
@@ -829,7 +810,8 @@ var Transport = class {
|
|
|
829
810
|
propagationCtx
|
|
830
811
|
}) {
|
|
831
812
|
let session = this.sessions.get(to);
|
|
832
|
-
|
|
813
|
+
const isReconnect = session !== void 0;
|
|
814
|
+
let isTransparentReconnect = isReconnect;
|
|
833
815
|
if (session?.advertisedSessionId !== void 0 && sessionId !== void 0 && session.advertisedSessionId !== sessionId) {
|
|
834
816
|
this.log?.info(
|
|
835
817
|
`session for ${to} already exists but has a different session id (expected: ${session.advertisedSessionId}, got: ${sessionId}), creating a new one`,
|
|
@@ -840,7 +822,7 @@ var Transport = class {
|
|
|
840
822
|
closeHandshakingConnection: handshakingConn !== void 0,
|
|
841
823
|
handshakingConn
|
|
842
824
|
});
|
|
843
|
-
|
|
825
|
+
isTransparentReconnect = false;
|
|
844
826
|
session = void 0;
|
|
845
827
|
}
|
|
846
828
|
if (!session) {
|
|
@@ -856,7 +838,7 @@ var Transport = class {
|
|
|
856
838
|
if (handshakingConn !== void 0) {
|
|
857
839
|
session.replaceWithNewHandshakingConnection(handshakingConn);
|
|
858
840
|
}
|
|
859
|
-
return { session, isReconnect };
|
|
841
|
+
return { session, isReconnect, isTransparentReconnect };
|
|
860
842
|
}
|
|
861
843
|
deleteSession({
|
|
862
844
|
session,
|
|
@@ -1132,12 +1114,16 @@ var ClientTransport = class extends Transport {
|
|
|
1132
1114
|
if (session) {
|
|
1133
1115
|
this.onDisconnect(conn, session);
|
|
1134
1116
|
}
|
|
1135
|
-
this.
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1117
|
+
const willReconnect = this.reconnectOnConnectionDrop && this.getStatus() === "open";
|
|
1118
|
+
this.log?.info(
|
|
1119
|
+
`connection to ${to} disconnected` + (willReconnect ? ", reconnecting" : ""),
|
|
1120
|
+
{
|
|
1121
|
+
...conn.loggingMetadata,
|
|
1122
|
+
...session?.loggingMetadata,
|
|
1123
|
+
clientId: this.clientId,
|
|
1124
|
+
connectedTo: to
|
|
1125
|
+
}
|
|
1126
|
+
);
|
|
1141
1127
|
this.inflightConnectionPromises.delete(to);
|
|
1142
1128
|
if (this.reconnectOnConnectionDrop) {
|
|
1143
1129
|
void this.connect(to);
|
|
@@ -1212,19 +1198,38 @@ var ClientTransport = class extends Transport {
|
|
|
1212
1198
|
);
|
|
1213
1199
|
return false;
|
|
1214
1200
|
}
|
|
1201
|
+
const previousSession = this.sessions.get(parsed.from);
|
|
1202
|
+
if (previousSession?.advertisedSessionId && previousSession.advertisedSessionId !== parsed.payload.status.sessionId) {
|
|
1203
|
+
this.deleteSession({
|
|
1204
|
+
session: previousSession,
|
|
1205
|
+
closeHandshakingConnection: true
|
|
1206
|
+
});
|
|
1207
|
+
conn.telemetry?.span.setStatus({
|
|
1208
|
+
code: import_api3.SpanStatusCode.ERROR,
|
|
1209
|
+
message: "session id mismatch"
|
|
1210
|
+
});
|
|
1211
|
+
this.log?.warn(`handshake from ${parsed.from} session id mismatch`, {
|
|
1212
|
+
...conn.loggingMetadata,
|
|
1213
|
+
clientId: this.clientId,
|
|
1214
|
+
connectedTo: parsed.from,
|
|
1215
|
+
transportMessage: parsed
|
|
1216
|
+
});
|
|
1217
|
+
this.protocolError(ProtocolError.HandshakeFailed, "session id mismatch");
|
|
1218
|
+
return false;
|
|
1219
|
+
}
|
|
1215
1220
|
this.log?.debug(`handshake from ${parsed.from} ok`, {
|
|
1216
1221
|
...conn.loggingMetadata,
|
|
1217
1222
|
clientId: this.clientId,
|
|
1218
1223
|
connectedTo: parsed.from,
|
|
1219
1224
|
transportMessage: parsed
|
|
1220
1225
|
});
|
|
1221
|
-
const { session,
|
|
1226
|
+
const { session, isTransparentReconnect } = this.getOrCreateSession({
|
|
1222
1227
|
to: parsed.from,
|
|
1223
1228
|
conn,
|
|
1224
1229
|
sessionId: parsed.payload.status.sessionId
|
|
1225
1230
|
});
|
|
1226
|
-
this.onConnect(conn,
|
|
1227
|
-
this.retryBudget.startRestoringBudget(
|
|
1231
|
+
this.onConnect(conn, session, isTransparentReconnect);
|
|
1232
|
+
this.retryBudget.startRestoringBudget(session.to);
|
|
1228
1233
|
return session;
|
|
1229
1234
|
}
|
|
1230
1235
|
/**
|
|
@@ -1232,6 +1237,13 @@ var ClientTransport = class extends Transport {
|
|
|
1232
1237
|
* @param to The client ID of the node to connect to.
|
|
1233
1238
|
*/
|
|
1234
1239
|
async connect(to) {
|
|
1240
|
+
if (this.connections.has(to)) {
|
|
1241
|
+
this.log?.info(`already connected to ${to}, skipping connect attempt`, {
|
|
1242
|
+
clientId: this.clientId,
|
|
1243
|
+
connectedTo: to
|
|
1244
|
+
});
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1235
1247
|
const canProceedWithConnection = () => this.getStatus() === "open";
|
|
1236
1248
|
if (!canProceedWithConnection()) {
|
|
1237
1249
|
this.log?.info(
|
|
@@ -1242,8 +1254,8 @@ var ClientTransport = class extends Transport {
|
|
|
1242
1254
|
}
|
|
1243
1255
|
let reconnectPromise = this.inflightConnectionPromises.get(to);
|
|
1244
1256
|
if (!reconnectPromise) {
|
|
1245
|
-
const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
|
|
1246
1257
|
if (!this.retryBudget.hasBudget(to)) {
|
|
1258
|
+
const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
|
|
1247
1259
|
const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
|
|
1248
1260
|
this.log?.error(errMsg, { clientId: this.clientId, connectedTo: to });
|
|
1249
1261
|
this.protocolError(ProtocolError.RetriesExceeded, errMsg);
|
|
@@ -1324,7 +1336,7 @@ var ClientTransport = class extends Transport {
|
|
|
1324
1336
|
clientId: this.clientId,
|
|
1325
1337
|
connectedTo: to
|
|
1326
1338
|
});
|
|
1327
|
-
|
|
1339
|
+
await this.connect(to);
|
|
1328
1340
|
}
|
|
1329
1341
|
}
|
|
1330
1342
|
}
|
|
@@ -1616,7 +1628,7 @@ var ServerTransport = class extends Transport {
|
|
|
1616
1628
|
if (parsedMetadata === false) {
|
|
1617
1629
|
return false;
|
|
1618
1630
|
}
|
|
1619
|
-
const { session,
|
|
1631
|
+
const { session, isTransparentReconnect } = this.getOrCreateSession({
|
|
1620
1632
|
to: parsed.from,
|
|
1621
1633
|
conn,
|
|
1622
1634
|
sessionId: parsed.payload.sessionId,
|
|
@@ -1632,7 +1644,7 @@ var ServerTransport = class extends Transport {
|
|
|
1632
1644
|
sessionId: session.id
|
|
1633
1645
|
});
|
|
1634
1646
|
conn.send(this.codec.toBuffer(responseMsg));
|
|
1635
|
-
this.onConnect(conn,
|
|
1647
|
+
this.onConnect(conn, session, isTransparentReconnect);
|
|
1636
1648
|
return session;
|
|
1637
1649
|
}
|
|
1638
1650
|
};
|