@replit/river 0.23.18 → 0.24.0
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/README.md +17 -16
- package/dist/{chunk-AVL32IMG.js → chunk-AASMR3CQ.js} +20 -16
- package/dist/chunk-AASMR3CQ.js.map +1 -0
- package/dist/chunk-JA57I7MG.js +653 -0
- package/dist/chunk-JA57I7MG.js.map +1 -0
- package/dist/chunk-KX5PQRVN.js +382 -0
- package/dist/chunk-KX5PQRVN.js.map +1 -0
- package/dist/{chunk-EV5HW4IC.js → chunk-KYYB4DUR.js} +65 -53
- package/dist/chunk-KYYB4DUR.js.map +1 -0
- package/dist/chunk-NLQPPDOT.js +399 -0
- package/dist/chunk-NLQPPDOT.js.map +1 -0
- package/dist/{chunk-R2HAS3GM.js → chunk-PJGGC3LV.js} +55 -41
- package/dist/chunk-PJGGC3LV.js.map +1 -0
- package/dist/{chunk-7MJYOL32.js → chunk-RXJLI2OP.js} +15 -23
- package/dist/chunk-RXJLI2OP.js.map +1 -0
- package/dist/{chunk-6LCL2ZZF.js → chunk-TAH2GVTJ.js} +1 -1
- package/dist/chunk-TAH2GVTJ.js.map +1 -0
- package/dist/chunk-ZAT3R4CU.js +277 -0
- package/dist/chunk-ZAT3R4CU.js.map +1 -0
- package/dist/{client-5776a6bb.d.ts → client-ba0d3315.d.ts} +12 -15
- package/dist/{connection-bd35d442.d.ts → connection-c3a96d09.d.ts} +1 -5
- package/dist/connection-d33e3246.d.ts +11 -0
- package/dist/{handshake-a947c234.d.ts → handshake-cdead82a.d.ts} +148 -183
- package/dist/logging/index.cjs.map +1 -1
- package/dist/logging/index.d.cts +1 -1
- package/dist/logging/index.d.ts +1 -1
- package/dist/logging/index.js +1 -1
- package/dist/{index-ea74cdbb.d.ts → message-e6c560fd.d.ts} +2 -2
- package/dist/router/index.cjs +104 -63
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +11 -10
- package/dist/router/index.d.ts +11 -10
- package/dist/router/index.js +2 -2
- package/dist/server-2ef5e6ec.d.ts +42 -0
- package/dist/{services-38b3f758.d.ts → services-e1417b33.d.ts} +3 -3
- package/dist/transport/impls/uds/client.cjs +1246 -1230
- package/dist/transport/impls/uds/client.cjs.map +1 -1
- package/dist/transport/impls/uds/client.d.cts +4 -4
- package/dist/transport/impls/uds/client.d.ts +4 -4
- package/dist/transport/impls/uds/client.js +7 -13
- package/dist/transport/impls/uds/client.js.map +1 -1
- package/dist/transport/impls/uds/server.cjs +1298 -1151
- package/dist/transport/impls/uds/server.cjs.map +1 -1
- package/dist/transport/impls/uds/server.d.cts +4 -4
- package/dist/transport/impls/uds/server.d.ts +4 -4
- package/dist/transport/impls/uds/server.js +6 -6
- package/dist/transport/impls/ws/client.cjs +976 -965
- 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 +6 -7
- package/dist/transport/impls/ws/client.js.map +1 -1
- package/dist/transport/impls/ws/server.cjs +1182 -1047
- 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 +6 -6
- package/dist/transport/index.cjs +1433 -1360
- 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 +9 -9
- package/dist/util/testHelpers.cjs +743 -310
- package/dist/util/testHelpers.cjs.map +1 -1
- package/dist/util/testHelpers.d.cts +9 -6
- package/dist/util/testHelpers.d.ts +9 -6
- package/dist/util/testHelpers.js +33 -10
- package/dist/util/testHelpers.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6LCL2ZZF.js.map +0 -1
- package/dist/chunk-7MJYOL32.js.map +0 -1
- package/dist/chunk-AVL32IMG.js.map +0 -1
- package/dist/chunk-DPKOJQWF.js +0 -476
- package/dist/chunk-DPKOJQWF.js.map +0 -1
- package/dist/chunk-EV5HW4IC.js.map +0 -1
- package/dist/chunk-J6N6H2WU.js +0 -476
- package/dist/chunk-J6N6H2WU.js.map +0 -1
- package/dist/chunk-MW5JXLHY.js +0 -348
- package/dist/chunk-MW5JXLHY.js.map +0 -1
- package/dist/chunk-R2HAS3GM.js.map +0 -1
- package/dist/chunk-RJOWZIWB.js +0 -335
- package/dist/chunk-RJOWZIWB.js.map +0 -1
- package/dist/connection-df85db7e.d.ts +0 -17
- package/dist/server-53cd5b7e.d.ts +0 -24
package/dist/router/index.cjs
CHANGED
|
@@ -612,7 +612,15 @@ function _pushable(getNext, options) {
|
|
|
612
612
|
|
|
613
613
|
// transport/message.ts
|
|
614
614
|
var import_typebox3 = require("@sinclair/typebox");
|
|
615
|
+
|
|
616
|
+
// transport/id.ts
|
|
615
617
|
var import_nanoid = require("nanoid");
|
|
618
|
+
var alphabet = (0, import_nanoid.customAlphabet)(
|
|
619
|
+
"1234567890abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ"
|
|
620
|
+
);
|
|
621
|
+
var generateId = () => alphabet(12);
|
|
622
|
+
|
|
623
|
+
// transport/message.ts
|
|
616
624
|
var TransportMessageSchema = (t) => import_typebox3.Type.Object({
|
|
617
625
|
id: import_typebox3.Type.String(),
|
|
618
626
|
from: import_typebox3.Type.String(),
|
|
@@ -646,18 +654,29 @@ var ControlMessageHandshakeRequestSchema = import_typebox3.Type.Object({
|
|
|
646
654
|
* used by the server to know whether this is a new or a reestablished connection, and whether it
|
|
647
655
|
* is compatible with what it already has.
|
|
648
656
|
*/
|
|
649
|
-
expectedSessionState: import_typebox3.Type.
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
})
|
|
658
|
-
),
|
|
657
|
+
expectedSessionState: import_typebox3.Type.Object({
|
|
658
|
+
// what the client expects the server to send next
|
|
659
|
+
nextExpectedSeq: import_typebox3.Type.Integer(),
|
|
660
|
+
// TODO: remove optional once we know all servers
|
|
661
|
+
// are nextSentSeq here
|
|
662
|
+
// what the server expects the client to send next
|
|
663
|
+
nextSentSeq: import_typebox3.Type.Optional(import_typebox3.Type.Integer())
|
|
664
|
+
}),
|
|
659
665
|
metadata: import_typebox3.Type.Optional(import_typebox3.Type.Unknown())
|
|
660
666
|
});
|
|
667
|
+
var HandshakeErrorRetriableResponseCodes = import_typebox3.Type.Union([
|
|
668
|
+
import_typebox3.Type.Literal("SESSION_STATE_MISMATCH")
|
|
669
|
+
]);
|
|
670
|
+
var HandshakeErrorFatalResponseCodes = import_typebox3.Type.Union([
|
|
671
|
+
import_typebox3.Type.Literal("MALFORMED_HANDSHAKE_META"),
|
|
672
|
+
import_typebox3.Type.Literal("MALFORMED_HANDSHAKE"),
|
|
673
|
+
import_typebox3.Type.Literal("PROTOCOL_VERSION_MISMATCH"),
|
|
674
|
+
import_typebox3.Type.Literal("REJECTED_BY_CUSTOM_HANDLER")
|
|
675
|
+
]);
|
|
676
|
+
var HandshakeErrorResponseCodes = import_typebox3.Type.Union([
|
|
677
|
+
HandshakeErrorRetriableResponseCodes,
|
|
678
|
+
HandshakeErrorFatalResponseCodes
|
|
679
|
+
]);
|
|
661
680
|
var ControlMessageHandshakeResponseSchema = import_typebox3.Type.Object({
|
|
662
681
|
type: import_typebox3.Type.Literal("HANDSHAKE_RESP"),
|
|
663
682
|
status: import_typebox3.Type.Union([
|
|
@@ -667,7 +686,10 @@ var ControlMessageHandshakeResponseSchema = import_typebox3.Type.Object({
|
|
|
667
686
|
}),
|
|
668
687
|
import_typebox3.Type.Object({
|
|
669
688
|
ok: import_typebox3.Type.Literal(false),
|
|
670
|
-
reason: import_typebox3.Type.String()
|
|
689
|
+
reason: import_typebox3.Type.String(),
|
|
690
|
+
// TODO: remove optional once we know all servers
|
|
691
|
+
// are sending code here
|
|
692
|
+
code: import_typebox3.Type.Optional(HandshakeErrorResponseCodes)
|
|
671
693
|
})
|
|
672
694
|
])
|
|
673
695
|
});
|
|
@@ -680,6 +702,15 @@ var ControlMessagePayloadSchema = import_typebox3.Type.Union([
|
|
|
680
702
|
var OpaqueTransportMessageSchema = TransportMessageSchema(
|
|
681
703
|
import_typebox3.Type.Unknown()
|
|
682
704
|
);
|
|
705
|
+
function closeStreamMessage(streamId) {
|
|
706
|
+
return {
|
|
707
|
+
streamId,
|
|
708
|
+
controlFlags: 4 /* StreamClosedBit */,
|
|
709
|
+
payload: {
|
|
710
|
+
type: "CLOSE"
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
}
|
|
683
714
|
function isStreamOpen(controlFlag) {
|
|
684
715
|
return (
|
|
685
716
|
/* eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison */
|
|
@@ -693,9 +724,6 @@ function isStreamClose(controlFlag) {
|
|
|
693
724
|
);
|
|
694
725
|
}
|
|
695
726
|
|
|
696
|
-
// router/client.ts
|
|
697
|
-
var import_nanoid2 = require("nanoid");
|
|
698
|
-
|
|
699
727
|
// router/result.ts
|
|
700
728
|
var import_typebox4 = require("@sinclair/typebox");
|
|
701
729
|
var UNCAUGHT_ERROR = "UNCAUGHT_ERROR";
|
|
@@ -724,7 +752,7 @@ function Err(error) {
|
|
|
724
752
|
var import_api = require("@opentelemetry/api");
|
|
725
753
|
|
|
726
754
|
// package.json
|
|
727
|
-
var version = "0.
|
|
755
|
+
var version = "0.24.0";
|
|
728
756
|
|
|
729
757
|
// tracing/index.ts
|
|
730
758
|
function getPropagationContext(ctx) {
|
|
@@ -818,7 +846,7 @@ function createClient(transport, serverId, providedClientOptions = {}) {
|
|
|
818
846
|
}
|
|
819
847
|
const options = { ...defaultClientOptions, ...providedClientOptions };
|
|
820
848
|
if (options.eagerlyConnect) {
|
|
821
|
-
|
|
849
|
+
transport.connect(serverId);
|
|
822
850
|
}
|
|
823
851
|
return _createRecursiveProxy(async (opts) => {
|
|
824
852
|
const [serviceName, procName, procType] = [...opts.path];
|
|
@@ -828,8 +856,8 @@ function createClient(transport, serverId, providedClientOptions = {}) {
|
|
|
828
856
|
);
|
|
829
857
|
}
|
|
830
858
|
const [input] = opts.args;
|
|
831
|
-
if (options.connectOnInvoke && !transport.
|
|
832
|
-
|
|
859
|
+
if (options.connectOnInvoke && !transport.sessions.has(serverId)) {
|
|
860
|
+
transport.connect(serverId);
|
|
833
861
|
}
|
|
834
862
|
if (procType === "rpc") {
|
|
835
863
|
return handleRpc(transport, serverId, input, serviceName, procName);
|
|
@@ -852,7 +880,7 @@ function createSessionDisconnectHandler(from, cb) {
|
|
|
852
880
|
};
|
|
853
881
|
}
|
|
854
882
|
function handleRpc(transport, serverId, input, serviceName, procedureName) {
|
|
855
|
-
const streamId = (
|
|
883
|
+
const streamId = generateId();
|
|
856
884
|
const { span, ctx } = createProcTelemetryInfo(
|
|
857
885
|
transport,
|
|
858
886
|
"rpc",
|
|
@@ -897,7 +925,7 @@ function handleRpc(transport, serverId, input, serviceName, procedureName) {
|
|
|
897
925
|
return responsePromise;
|
|
898
926
|
}
|
|
899
927
|
function handleStream(transport, serverId, init, serviceName, procedureName) {
|
|
900
|
-
const streamId = (
|
|
928
|
+
const streamId = generateId();
|
|
901
929
|
const { span, ctx } = createProcTelemetryInfo(
|
|
902
930
|
transport,
|
|
903
931
|
"stream",
|
|
@@ -938,7 +966,7 @@ function handleStream(transport, serverId, init, serviceName, procedureName) {
|
|
|
938
966
|
}
|
|
939
967
|
if (!healthyClose)
|
|
940
968
|
return;
|
|
941
|
-
transport.
|
|
969
|
+
transport.send(serverId, closeStreamMessage(streamId));
|
|
942
970
|
};
|
|
943
971
|
void pipeInputToTransport();
|
|
944
972
|
function onMessage(msg) {
|
|
@@ -974,7 +1002,7 @@ function handleStream(transport, serverId, init, serviceName, procedureName) {
|
|
|
974
1002
|
return [inputStream, outputStream, cleanup];
|
|
975
1003
|
}
|
|
976
1004
|
function handleSubscribe(transport, serverId, input, serviceName, procedureName) {
|
|
977
|
-
const streamId = (
|
|
1005
|
+
const streamId = generateId();
|
|
978
1006
|
const { span, ctx } = createProcTelemetryInfo(
|
|
979
1007
|
transport,
|
|
980
1008
|
"subscription",
|
|
@@ -1013,7 +1041,7 @@ function handleSubscribe(transport, serverId, input, serviceName, procedureName)
|
|
|
1013
1041
|
cleanup();
|
|
1014
1042
|
if (!healthyClose)
|
|
1015
1043
|
return;
|
|
1016
|
-
transport.
|
|
1044
|
+
transport.send(serverId, closeStreamMessage(streamId));
|
|
1017
1045
|
};
|
|
1018
1046
|
const onSessionStatus = createSessionDisconnectHandler(serverId, () => {
|
|
1019
1047
|
outputStream.push(
|
|
@@ -1030,7 +1058,7 @@ function handleSubscribe(transport, serverId, input, serviceName, procedureName)
|
|
|
1030
1058
|
return [outputStream, closeHandler];
|
|
1031
1059
|
}
|
|
1032
1060
|
function handleUpload(transport, serverId, init, serviceName, procedureName) {
|
|
1033
|
-
const streamId = (
|
|
1061
|
+
const streamId = generateId();
|
|
1034
1062
|
const { span, ctx } = createProcTelemetryInfo(
|
|
1035
1063
|
transport,
|
|
1036
1064
|
"upload",
|
|
@@ -1070,7 +1098,7 @@ function handleUpload(transport, serverId, init, serviceName, procedureName) {
|
|
|
1070
1098
|
}
|
|
1071
1099
|
if (!healthyClose)
|
|
1072
1100
|
return;
|
|
1073
|
-
transport.
|
|
1101
|
+
transport.send(serverId, closeStreamMessage(streamId));
|
|
1074
1102
|
};
|
|
1075
1103
|
void pipeInputToTransport();
|
|
1076
1104
|
const responsePromise = new Promise((resolve) => {
|
|
@@ -1121,11 +1149,11 @@ var RiverServer = class {
|
|
|
1121
1149
|
transport;
|
|
1122
1150
|
services;
|
|
1123
1151
|
contextMap;
|
|
1124
|
-
// map of streamId to ProcStream
|
|
1125
1152
|
streamMap;
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1153
|
+
sessionToStreamId;
|
|
1154
|
+
// streams that are in the process of being cleaned up
|
|
1155
|
+
// this is to prevent output handlers from sending after the stream is cleaned up
|
|
1156
|
+
sessionsBeingCleanedUp = /* @__PURE__ */ new Set();
|
|
1129
1157
|
log;
|
|
1130
1158
|
constructor(transport, services, handshakeOptions, extendedContext) {
|
|
1131
1159
|
const instances = {};
|
|
@@ -1143,9 +1171,8 @@ var RiverServer = class {
|
|
|
1143
1171
|
transport.extendHandshake(handshakeOptions);
|
|
1144
1172
|
}
|
|
1145
1173
|
this.transport = transport;
|
|
1146
|
-
this.disconnectedSessions = /* @__PURE__ */ new Set();
|
|
1147
1174
|
this.streamMap = /* @__PURE__ */ new Map();
|
|
1148
|
-
this.
|
|
1175
|
+
this.sessionToStreamId = /* @__PURE__ */ new Map();
|
|
1149
1176
|
this.transport.addEventListener("message", this.onMessage);
|
|
1150
1177
|
this.transport.addEventListener("sessionStatus", this.onSessionStatus);
|
|
1151
1178
|
this.log = transport.log;
|
|
@@ -1180,24 +1207,35 @@ var RiverServer = class {
|
|
|
1180
1207
|
}
|
|
1181
1208
|
await this.pushToStream(procStream, message, isInitMessage);
|
|
1182
1209
|
};
|
|
1183
|
-
// cleanup streams on session close
|
|
1184
1210
|
onSessionStatus = async (evt) => {
|
|
1185
|
-
|
|
1211
|
+
const streamsFromThisClient = this.sessionToStreamId.get(evt.session.id);
|
|
1212
|
+
const cleanupStreams = async (ids) => {
|
|
1213
|
+
this.sessionsBeingCleanedUp.add(evt.session.id);
|
|
1214
|
+
await Promise.all(Array.from(ids).map(this.cleanupStream));
|
|
1215
|
+
this.sessionToStreamId.delete(evt.session.id);
|
|
1216
|
+
this.sessionsBeingCleanedUp.delete(evt.session.id);
|
|
1217
|
+
};
|
|
1218
|
+
if (evt.status === "connect") {
|
|
1219
|
+
if (streamsFromThisClient) {
|
|
1220
|
+
this.log?.error(
|
|
1221
|
+
`got session connect from ${evt.session.to} but there are still streams open from this session`,
|
|
1222
|
+
{
|
|
1223
|
+
clientId: this.transport.clientId,
|
|
1224
|
+
tags: ["invariant-violation"]
|
|
1225
|
+
}
|
|
1226
|
+
);
|
|
1227
|
+
await cleanupStreams(streamsFromThisClient);
|
|
1228
|
+
}
|
|
1229
|
+
this.sessionToStreamId.set(evt.session.id, /* @__PURE__ */ new Set());
|
|
1186
1230
|
return;
|
|
1187
|
-
|
|
1231
|
+
}
|
|
1188
1232
|
this.log?.info(
|
|
1189
|
-
`got session disconnect from ${
|
|
1233
|
+
`got session disconnect from ${evt.session.to}, cleaning up streams for session`,
|
|
1190
1234
|
evt.session.loggingMetadata
|
|
1191
1235
|
);
|
|
1192
|
-
const streamsFromThisClient = this.clientStreams.get(disconnectedClientId);
|
|
1193
1236
|
if (!streamsFromThisClient)
|
|
1194
1237
|
return;
|
|
1195
|
-
|
|
1196
|
-
await Promise.all(
|
|
1197
|
-
Array.from(streamsFromThisClient).map(this.cleanupStream)
|
|
1198
|
-
);
|
|
1199
|
-
this.disconnectedSessions.delete(disconnectedClientId);
|
|
1200
|
-
this.clientStreams.delete(disconnectedClientId);
|
|
1238
|
+
await cleanupStreams(streamsFromThisClient);
|
|
1201
1239
|
};
|
|
1202
1240
|
createNewProcStream(message) {
|
|
1203
1241
|
if (!isStreamOpen(message.controlFlags)) {
|
|
@@ -1248,26 +1286,34 @@ var RiverServer = class {
|
|
|
1248
1286
|
});
|
|
1249
1287
|
return;
|
|
1250
1288
|
}
|
|
1289
|
+
const {
|
|
1290
|
+
to,
|
|
1291
|
+
id: sessionId,
|
|
1292
|
+
loggingMetadata: sessionLoggingMetadata
|
|
1293
|
+
} = session;
|
|
1251
1294
|
const procedure = service.procedures[message.procedureName];
|
|
1252
1295
|
const incoming = pushable({ objectMode: true });
|
|
1253
1296
|
const outgoing = pushable({ objectMode: true });
|
|
1254
1297
|
const needsClose = procedure.type === "subscription" || procedure.type === "stream";
|
|
1255
1298
|
const disposables = [];
|
|
1299
|
+
const wrappedSend = (payload) => {
|
|
1300
|
+
if (!this.sessionsBeingCleanedUp.has(sessionId)) {
|
|
1301
|
+
this.transport.send(to, payload);
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1256
1304
|
const outputHandler = (
|
|
1257
1305
|
// sending outgoing messages back to client
|
|
1258
1306
|
needsClose ? (
|
|
1259
1307
|
// subscription and stream case, we need to send a close bit after the response stream
|
|
1260
1308
|
(async () => {
|
|
1261
1309
|
for await (const response of outgoing) {
|
|
1262
|
-
|
|
1310
|
+
wrappedSend({
|
|
1263
1311
|
streamId: message.streamId,
|
|
1264
1312
|
controlFlags: 0,
|
|
1265
1313
|
payload: response
|
|
1266
1314
|
});
|
|
1267
1315
|
}
|
|
1268
|
-
|
|
1269
|
-
this.transport.sendCloseStream(session.to, message.streamId);
|
|
1270
|
-
}
|
|
1316
|
+
wrappedSend(closeStreamMessage(message.streamId));
|
|
1271
1317
|
disposables.forEach((d) => d());
|
|
1272
1318
|
})()
|
|
1273
1319
|
) : (
|
|
@@ -1275,7 +1321,7 @@ var RiverServer = class {
|
|
|
1275
1321
|
(async () => {
|
|
1276
1322
|
const response = await outgoing.next().then((res) => res.value);
|
|
1277
1323
|
if (response) {
|
|
1278
|
-
|
|
1324
|
+
wrappedSend({
|
|
1279
1325
|
streamId: message.streamId,
|
|
1280
1326
|
controlFlags: 4 /* StreamClosedBit */,
|
|
1281
1327
|
payload: response
|
|
@@ -1289,7 +1335,7 @@ var RiverServer = class {
|
|
|
1289
1335
|
const errorMsg = coerceErrorString(err);
|
|
1290
1336
|
this.log?.error(
|
|
1291
1337
|
`procedure ${message.serviceName}.${message.procedureName} threw an uncaught error: ${errorMsg}`,
|
|
1292
|
-
|
|
1338
|
+
sessionLoggingMetadata
|
|
1293
1339
|
);
|
|
1294
1340
|
span.recordException(err instanceof Error ? err : new Error(errorMsg));
|
|
1295
1341
|
span.setStatus({ code: import_api2.SpanStatusCode.ERROR });
|
|
@@ -1300,10 +1346,10 @@ var RiverServer = class {
|
|
|
1300
1346
|
})
|
|
1301
1347
|
);
|
|
1302
1348
|
};
|
|
1303
|
-
const sessionMeta = this.transport.sessionHandshakeMetadata.get(
|
|
1349
|
+
const sessionMeta = this.transport.sessionHandshakeMetadata.get(to);
|
|
1304
1350
|
if (!sessionMeta) {
|
|
1305
1351
|
this.log?.error(`session doesn't have handshake metadata`, {
|
|
1306
|
-
...
|
|
1352
|
+
...sessionLoggingMetadata,
|
|
1307
1353
|
tags: ["invariant-violation"]
|
|
1308
1354
|
});
|
|
1309
1355
|
return;
|
|
@@ -1315,7 +1361,6 @@ var RiverServer = class {
|
|
|
1315
1361
|
to: message.to,
|
|
1316
1362
|
from: message.from,
|
|
1317
1363
|
streamId: message.streamId,
|
|
1318
|
-
session,
|
|
1319
1364
|
metadata: sessionMeta
|
|
1320
1365
|
};
|
|
1321
1366
|
switch (procedure.type) {
|
|
@@ -1434,9 +1479,7 @@ var RiverServer = class {
|
|
|
1434
1479
|
initMessage.value,
|
|
1435
1480
|
incoming
|
|
1436
1481
|
);
|
|
1437
|
-
|
|
1438
|
-
outgoing.push(outputMessage);
|
|
1439
|
-
}
|
|
1482
|
+
outgoing.push(outputMessage);
|
|
1440
1483
|
} catch (err) {
|
|
1441
1484
|
errorHandler(err, span);
|
|
1442
1485
|
} finally {
|
|
@@ -1454,9 +1497,7 @@ var RiverServer = class {
|
|
|
1454
1497
|
serviceContextWithTransportInfo,
|
|
1455
1498
|
incoming
|
|
1456
1499
|
);
|
|
1457
|
-
|
|
1458
|
-
outgoing.push(outputMessage);
|
|
1459
|
-
}
|
|
1500
|
+
outgoing.push(outputMessage);
|
|
1460
1501
|
} catch (err) {
|
|
1461
1502
|
errorHandler(err, span);
|
|
1462
1503
|
} finally {
|
|
@@ -1469,7 +1510,7 @@ var RiverServer = class {
|
|
|
1469
1510
|
default:
|
|
1470
1511
|
this.log?.warn(
|
|
1471
1512
|
`got request for invalid procedure type ${procedure.type} at ${message.serviceName}.${message.procedureName}`,
|
|
1472
|
-
{ ...
|
|
1513
|
+
{ ...sessionLoggingMetadata, transportMessage: message }
|
|
1473
1514
|
);
|
|
1474
1515
|
return;
|
|
1475
1516
|
}
|
|
@@ -1482,9 +1523,9 @@ var RiverServer = class {
|
|
|
1482
1523
|
promises: { inputHandler, outputHandler }
|
|
1483
1524
|
};
|
|
1484
1525
|
this.streamMap.set(message.streamId, procStream);
|
|
1485
|
-
const
|
|
1486
|
-
|
|
1487
|
-
this.
|
|
1526
|
+
const streamsForThisSession = this.sessionToStreamId.get(sessionId) ?? /* @__PURE__ */ new Set();
|
|
1527
|
+
streamsForThisSession.add(message.streamId);
|
|
1528
|
+
this.sessionToStreamId.set(sessionId, streamsForThisSession);
|
|
1488
1529
|
return procStream;
|
|
1489
1530
|
}
|
|
1490
1531
|
async pushToStream(procStream, message, isInit) {
|
|
@@ -1520,11 +1561,11 @@ var RiverServer = class {
|
|
|
1520
1561
|
}
|
|
1521
1562
|
if (isStreamClose(message.controlFlags)) {
|
|
1522
1563
|
await this.cleanupStream(message.streamId);
|
|
1523
|
-
const streamsFromThisClient = this.
|
|
1564
|
+
const streamsFromThisClient = this.sessionToStreamId.get(message.from);
|
|
1524
1565
|
if (streamsFromThisClient) {
|
|
1525
1566
|
streamsFromThisClient.delete(message.streamId);
|
|
1526
1567
|
if (streamsFromThisClient.size === 0) {
|
|
1527
|
-
this.
|
|
1568
|
+
this.sessionToStreamId.delete(message.from);
|
|
1528
1569
|
}
|
|
1529
1570
|
}
|
|
1530
1571
|
}
|