@replit/river 0.214.0 → 0.215.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/dist/{adapter-Cp7_gIVA.d.ts → adapter-CgF7vQPu.d.ts} +3 -2
- package/dist/{adapter-DjiEwOYi.d.cts → adapter-IGrG4KLL.d.cts} +3 -2
- package/dist/{chunk-LECVFB2G.js → chunk-RDTQZ7HO.js} +15 -10
- package/dist/chunk-RDTQZ7HO.js.map +1 -0
- package/dist/{chunk-DRYCLL6N.js → chunk-VXRAFUA3.js} +178 -54
- package/dist/chunk-VXRAFUA3.js.map +1 -0
- package/dist/{client-Dw0JBBs3.d.ts → client-BhwlY0-L.d.ts} +2 -2
- package/dist/{client-DXJRow2s.d.cts → client-Dk4H7qeg.d.cts} +2 -2
- package/dist/codec/index.cjs.map +1 -1
- package/dist/codec/index.d.cts +3 -3
- package/dist/codec/index.d.ts +3 -3
- package/dist/codec/index.js +2 -2
- package/dist/{connection-Dzkqj18h.d.cts → connection-CS00EWuS.d.cts} +3 -3
- package/dist/{connection-C2lYgRh0.d.ts → connection-DU9v3y8a.d.ts} +3 -3
- package/dist/{index-D9R6UTMl.d.cts → index-CHCzvZ9D.d.cts} +1 -1
- package/dist/{index-CSM8soK7.d.ts → index-uF0cBM7z.d.ts} +1 -1
- package/dist/logging/index.d.cts +2 -2
- package/dist/logging/index.d.ts +2 -2
- package/dist/{message-Dlsh5WDF.d.cts → message-aABg0s5M.d.cts} +12 -1
- package/dist/{message-Dlsh5WDF.d.ts → message-aABg0s5M.d.ts} +12 -1
- package/dist/router/index.cjs +14 -9
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +10 -10
- package/dist/router/index.d.ts +10 -10
- package/dist/router/index.js +1 -1
- package/dist/{server-BDSYa-CO.d.cts → server-BR0DZaWi.d.cts} +4 -4
- package/dist/{server-DFOzjvLh.d.ts → server-uNzkzIRh.d.ts} +4 -4
- package/dist/{services-D47_GPCH.d.ts → services-B5SY771g.d.ts} +3 -3
- package/dist/{services-DqYQvm_L.d.cts → services-DBv2nmly.d.cts} +3 -3
- package/dist/testUtil/index.cjs +179 -53
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +7 -7
- package/dist/testUtil/index.d.ts +7 -7
- package/dist/testUtil/index.js +4 -2
- package/dist/testUtil/index.js.map +1 -1
- package/dist/transport/impls/ws/client.cjs +166 -53
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +6 -6
- package/dist/transport/impls/ws/client.d.ts +6 -6
- package/dist/transport/impls/ws/client.js +2 -2
- package/dist/transport/impls/ws/server.cjs +133 -53
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +6 -6
- package/dist/transport/impls/ws/server.d.ts +6 -6
- package/dist/transport/impls/ws/server.js +2 -2
- package/dist/transport/index.cjs +177 -53
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +7 -7
- package/dist/transport/index.d.ts +7 -7
- package/dist/transport/index.js +2 -2
- package/dist/{transport-CxT7y8Qk.d.cts → transport-BOL2p5s-.d.ts} +70 -64
- package/dist/{transport-pdbkDzmJ.d.ts → transport-D3jzhFSi.d.cts} +70 -64
- package/package.json +1 -1
- package/dist/chunk-DRYCLL6N.js.map +0 -1
- package/dist/chunk-LECVFB2G.js.map +0 -1
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
handshakeResponseMessage,
|
|
21
21
|
isAcceptedProtocolVersion,
|
|
22
22
|
isAck
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-RDTQZ7HO.js";
|
|
24
24
|
|
|
25
25
|
// transport/events.ts
|
|
26
26
|
var ProtocolError = {
|
|
@@ -226,6 +226,7 @@ var IdentifiedSession = class extends CommonSession {
|
|
|
226
226
|
telemetry;
|
|
227
227
|
to;
|
|
228
228
|
protocolVersion;
|
|
229
|
+
listeners;
|
|
229
230
|
/**
|
|
230
231
|
* Index of the message we will send next (excluding handshake)
|
|
231
232
|
*/
|
|
@@ -249,7 +250,8 @@ var IdentifiedSession = class extends CommonSession {
|
|
|
249
250
|
telemetry,
|
|
250
251
|
log,
|
|
251
252
|
protocolVersion,
|
|
252
|
-
seqSent: messagesSent
|
|
253
|
+
seqSent: messagesSent,
|
|
254
|
+
listeners
|
|
253
255
|
} = props;
|
|
254
256
|
super(props);
|
|
255
257
|
this.id = id;
|
|
@@ -261,6 +263,7 @@ var IdentifiedSession = class extends CommonSession {
|
|
|
261
263
|
this.log = log;
|
|
262
264
|
this.protocolVersion = protocolVersion;
|
|
263
265
|
this.seqSent = messagesSent;
|
|
266
|
+
this.listeners = listeners;
|
|
264
267
|
}
|
|
265
268
|
get loggingMetadata() {
|
|
266
269
|
const metadata = {
|
|
@@ -277,7 +280,7 @@ var IdentifiedSession = class extends CommonSession {
|
|
|
277
280
|
}
|
|
278
281
|
return metadata;
|
|
279
282
|
}
|
|
280
|
-
|
|
283
|
+
encodeMsg(partialMsg) {
|
|
281
284
|
const msg = {
|
|
282
285
|
...partialMsg,
|
|
283
286
|
id: generateId(),
|
|
@@ -286,18 +289,37 @@ var IdentifiedSession = class extends CommonSession {
|
|
|
286
289
|
seq: this.seq,
|
|
287
290
|
ack: this.ack
|
|
288
291
|
};
|
|
292
|
+
const encoded = this.codec.toBuffer(msg);
|
|
293
|
+
if (!encoded.ok) {
|
|
294
|
+
this.listeners.onMessageSendFailure(
|
|
295
|
+
{ ...partialMsg, seq: this.seq },
|
|
296
|
+
encoded.reason
|
|
297
|
+
);
|
|
298
|
+
return encoded;
|
|
299
|
+
}
|
|
289
300
|
this.seq++;
|
|
290
|
-
return
|
|
301
|
+
return {
|
|
302
|
+
ok: true,
|
|
303
|
+
value: {
|
|
304
|
+
id: msg.id,
|
|
305
|
+
seq: msg.seq,
|
|
306
|
+
msg: partialMsg,
|
|
307
|
+
data: encoded.value
|
|
308
|
+
}
|
|
309
|
+
};
|
|
291
310
|
}
|
|
292
311
|
nextSeq() {
|
|
293
312
|
return this.sendBuffer.length > 0 ? this.sendBuffer[0].seq : this.seq;
|
|
294
313
|
}
|
|
295
314
|
send(msg) {
|
|
296
|
-
const
|
|
297
|
-
|
|
315
|
+
const encodeResult = this.encodeMsg(msg);
|
|
316
|
+
if (!encodeResult.ok) {
|
|
317
|
+
return encodeResult;
|
|
318
|
+
}
|
|
319
|
+
this.sendBuffer.push(encodeResult.value);
|
|
298
320
|
return {
|
|
299
321
|
ok: true,
|
|
300
|
-
value:
|
|
322
|
+
value: encodeResult.value.id
|
|
301
323
|
};
|
|
302
324
|
}
|
|
303
325
|
_handleStateExit() {
|
|
@@ -330,23 +352,6 @@ var IdentifiedSessionWithGracePeriod = class extends IdentifiedSession {
|
|
|
330
352
|
super._handleClose();
|
|
331
353
|
}
|
|
332
354
|
};
|
|
333
|
-
function sendMessage(conn, codec, msg) {
|
|
334
|
-
const buff = codec.toBuffer(msg);
|
|
335
|
-
if (!buff.ok) {
|
|
336
|
-
return buff;
|
|
337
|
-
}
|
|
338
|
-
const sent = conn.send(buff.value);
|
|
339
|
-
if (!sent) {
|
|
340
|
-
return {
|
|
341
|
-
ok: false,
|
|
342
|
-
reason: "failed to send message"
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
return {
|
|
346
|
-
ok: true,
|
|
347
|
-
value: msg.id
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
355
|
|
|
351
356
|
// transport/sessionStateMachine/SessionConnecting.ts
|
|
352
357
|
var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
|
|
@@ -449,7 +454,21 @@ var SessionWaitingForHandshake = class extends CommonSession {
|
|
|
449
454
|
this.listeners.onHandshake(parsedMsgRes.value);
|
|
450
455
|
};
|
|
451
456
|
sendHandshake(msg) {
|
|
452
|
-
|
|
457
|
+
const buff = this.codec.toBuffer(msg);
|
|
458
|
+
if (!buff.ok) {
|
|
459
|
+
return buff;
|
|
460
|
+
}
|
|
461
|
+
const sent = this.conn.send(buff.value);
|
|
462
|
+
if (!sent) {
|
|
463
|
+
return {
|
|
464
|
+
ok: false,
|
|
465
|
+
reason: "failed to send handshake"
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
return {
|
|
469
|
+
ok: true,
|
|
470
|
+
value: msg.id
|
|
471
|
+
};
|
|
453
472
|
}
|
|
454
473
|
_handleStateExit() {
|
|
455
474
|
this.conn.removeDataListener();
|
|
@@ -498,7 +517,21 @@ var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
|
|
|
498
517
|
this.listeners.onHandshake(parsedMsgRes.value);
|
|
499
518
|
};
|
|
500
519
|
sendHandshake(msg) {
|
|
501
|
-
|
|
520
|
+
const buff = this.codec.toBuffer(msg);
|
|
521
|
+
if (!buff.ok) {
|
|
522
|
+
return buff;
|
|
523
|
+
}
|
|
524
|
+
const sent = this.conn.send(buff.value);
|
|
525
|
+
if (!sent) {
|
|
526
|
+
return {
|
|
527
|
+
ok: false,
|
|
528
|
+
reason: "failed to send handshake"
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
return {
|
|
532
|
+
ok: true,
|
|
533
|
+
value: msg.id
|
|
534
|
+
};
|
|
502
535
|
}
|
|
503
536
|
_handleStateExit() {
|
|
504
537
|
super._handleStateExit();
|
|
@@ -533,28 +566,35 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
533
566
|
}
|
|
534
567
|
this.startMissingHeartbeatTimeout();
|
|
535
568
|
}
|
|
536
|
-
assertSendOrdering(
|
|
537
|
-
if (
|
|
538
|
-
const msg = `invariant violation: would have sent out of order msg (seq: ${
|
|
569
|
+
assertSendOrdering(encodedMsg) {
|
|
570
|
+
if (encodedMsg.seq > this.seqSent + 1) {
|
|
571
|
+
const msg = `invariant violation: would have sent out of order msg (seq: ${encodedMsg.seq}, expected: ${this.seqSent} + 1)`;
|
|
539
572
|
this.log?.error(msg, {
|
|
540
573
|
...this.loggingMetadata,
|
|
541
|
-
transportMessage: constructedMsg,
|
|
542
574
|
tags: ["invariant-violation"]
|
|
543
575
|
});
|
|
544
576
|
throw new Error(msg);
|
|
545
577
|
}
|
|
546
578
|
}
|
|
547
579
|
send(msg) {
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
580
|
+
const encodeResult = this.encodeMsg(msg);
|
|
581
|
+
if (!encodeResult.ok) {
|
|
582
|
+
return encodeResult;
|
|
583
|
+
}
|
|
584
|
+
const encodedMsg = encodeResult.value;
|
|
585
|
+
this.assertSendOrdering(encodedMsg);
|
|
586
|
+
this.sendBuffer.push(encodedMsg);
|
|
587
|
+
const sent = this.conn.send(encodedMsg.data);
|
|
588
|
+
if (!sent) {
|
|
589
|
+
const reason = "failed to send message";
|
|
590
|
+
this.listeners.onMessageSendFailure(
|
|
591
|
+
{ ...encodedMsg.msg, seq: encodedMsg.seq },
|
|
592
|
+
reason
|
|
593
|
+
);
|
|
594
|
+
return { ok: false, reason };
|
|
555
595
|
}
|
|
556
|
-
this.seqSent =
|
|
557
|
-
return
|
|
596
|
+
this.seqSent = encodedMsg.seq;
|
|
597
|
+
return { ok: true, value: encodedMsg.id };
|
|
558
598
|
}
|
|
559
599
|
constructor(props) {
|
|
560
600
|
super(props);
|
|
@@ -572,10 +612,14 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
572
612
|
);
|
|
573
613
|
for (const msg of this.sendBuffer) {
|
|
574
614
|
this.assertSendOrdering(msg);
|
|
575
|
-
const
|
|
576
|
-
if (!
|
|
577
|
-
|
|
578
|
-
|
|
615
|
+
const sent = this.conn.send(msg.data);
|
|
616
|
+
if (!sent) {
|
|
617
|
+
const reason = "failed to send buffered message";
|
|
618
|
+
this.listeners.onMessageSendFailure(
|
|
619
|
+
{ ...msg.msg, seq: msg.seq },
|
|
620
|
+
reason
|
|
621
|
+
);
|
|
622
|
+
return { ok: false, reason };
|
|
579
623
|
}
|
|
580
624
|
this.seqSent = msg.seq;
|
|
581
625
|
}
|
|
@@ -1278,6 +1322,17 @@ var Transport = class {
|
|
|
1278
1322
|
const noConnectionSession = SessionStateGraph.transition.ConnectingToNoConnection(session, {
|
|
1279
1323
|
onSessionGracePeriodElapsed: () => {
|
|
1280
1324
|
this.onSessionGracePeriodElapsed(noConnectionSession);
|
|
1325
|
+
},
|
|
1326
|
+
onMessageSendFailure: (msg, reason) => {
|
|
1327
|
+
this.log?.error(`failed to send message: ${reason}`, {
|
|
1328
|
+
...noConnectionSession.loggingMetadata,
|
|
1329
|
+
transportMessage: msg
|
|
1330
|
+
});
|
|
1331
|
+
this.protocolError({
|
|
1332
|
+
type: ProtocolError.MessageSendFailure,
|
|
1333
|
+
message: reason
|
|
1334
|
+
});
|
|
1335
|
+
this.deleteSession(noConnectionSession, { unhealthy: true });
|
|
1281
1336
|
}
|
|
1282
1337
|
});
|
|
1283
1338
|
this.updateSession(noConnectionSession);
|
|
@@ -1285,18 +1340,32 @@ var Transport = class {
|
|
|
1285
1340
|
}
|
|
1286
1341
|
onConnClosed(session) {
|
|
1287
1342
|
let noConnectionSession;
|
|
1343
|
+
const listeners = {
|
|
1344
|
+
onSessionGracePeriodElapsed: () => {
|
|
1345
|
+
this.onSessionGracePeriodElapsed(noConnectionSession);
|
|
1346
|
+
},
|
|
1347
|
+
onMessageSendFailure: (msg, reason) => {
|
|
1348
|
+
this.log?.error(`failed to send message: ${reason}`, {
|
|
1349
|
+
...noConnectionSession.loggingMetadata,
|
|
1350
|
+
transportMessage: msg
|
|
1351
|
+
});
|
|
1352
|
+
this.protocolError({
|
|
1353
|
+
type: ProtocolError.MessageSendFailure,
|
|
1354
|
+
message: reason
|
|
1355
|
+
});
|
|
1356
|
+
this.deleteSession(noConnectionSession, { unhealthy: true });
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1288
1359
|
if (session.state === "Handshaking" /* Handshaking */) {
|
|
1289
|
-
noConnectionSession = SessionStateGraph.transition.HandshakingToNoConnection(
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
});
|
|
1360
|
+
noConnectionSession = SessionStateGraph.transition.HandshakingToNoConnection(
|
|
1361
|
+
session,
|
|
1362
|
+
listeners
|
|
1363
|
+
);
|
|
1294
1364
|
} else {
|
|
1295
|
-
noConnectionSession = SessionStateGraph.transition.ConnectedToNoConnection(
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
});
|
|
1365
|
+
noConnectionSession = SessionStateGraph.transition.ConnectedToNoConnection(
|
|
1366
|
+
session,
|
|
1367
|
+
listeners
|
|
1368
|
+
);
|
|
1300
1369
|
}
|
|
1301
1370
|
this.updateSession(noConnectionSession);
|
|
1302
1371
|
return noConnectionSession;
|
|
@@ -1457,6 +1526,17 @@ var ClientTransport = class extends Transport {
|
|
|
1457
1526
|
{
|
|
1458
1527
|
onSessionGracePeriodElapsed: () => {
|
|
1459
1528
|
this.onSessionGracePeriodElapsed(session);
|
|
1529
|
+
},
|
|
1530
|
+
onMessageSendFailure: (msg, reason) => {
|
|
1531
|
+
this.log?.error(`failed to send message: ${reason}`, {
|
|
1532
|
+
...session.loggingMetadata,
|
|
1533
|
+
transportMessage: msg
|
|
1534
|
+
});
|
|
1535
|
+
this.protocolError({
|
|
1536
|
+
type: ProtocolError.MessageSendFailure,
|
|
1537
|
+
message: reason
|
|
1538
|
+
});
|
|
1539
|
+
this.deleteSession(session, { unhealthy: true });
|
|
1460
1540
|
}
|
|
1461
1541
|
},
|
|
1462
1542
|
this.options,
|
|
@@ -1521,6 +1601,17 @@ var ClientTransport = class extends Transport {
|
|
|
1521
1601
|
},
|
|
1522
1602
|
onSessionGracePeriodElapsed: () => {
|
|
1523
1603
|
this.onSessionGracePeriodElapsed(handshakingSession);
|
|
1604
|
+
},
|
|
1605
|
+
onMessageSendFailure: (msg, reason) => {
|
|
1606
|
+
this.log?.error(`failed to send message: ${reason}`, {
|
|
1607
|
+
...handshakingSession.loggingMetadata,
|
|
1608
|
+
transportMessage: msg
|
|
1609
|
+
});
|
|
1610
|
+
this.protocolError({
|
|
1611
|
+
type: ProtocolError.MessageSendFailure,
|
|
1612
|
+
message: reason
|
|
1613
|
+
});
|
|
1614
|
+
this.deleteSession(handshakingSession, { unhealthy: true });
|
|
1524
1615
|
}
|
|
1525
1616
|
}
|
|
1526
1617
|
);
|
|
@@ -1682,6 +1773,17 @@ var ClientTransport = class extends Transport {
|
|
|
1682
1773
|
},
|
|
1683
1774
|
onSessionGracePeriodElapsed: () => {
|
|
1684
1775
|
this.onSessionGracePeriodElapsed(backingOffSession);
|
|
1776
|
+
},
|
|
1777
|
+
onMessageSendFailure: (msg, reason) => {
|
|
1778
|
+
this.log?.error(`failed to send message: ${reason}`, {
|
|
1779
|
+
...backingOffSession.loggingMetadata,
|
|
1780
|
+
transportMessage: msg
|
|
1781
|
+
});
|
|
1782
|
+
this.protocolError({
|
|
1783
|
+
type: ProtocolError.MessageSendFailure,
|
|
1784
|
+
message: reason
|
|
1785
|
+
});
|
|
1786
|
+
this.deleteSession(backingOffSession, { unhealthy: true });
|
|
1685
1787
|
}
|
|
1686
1788
|
}
|
|
1687
1789
|
);
|
|
@@ -1745,6 +1847,17 @@ var ClientTransport = class extends Transport {
|
|
|
1745
1847
|
},
|
|
1746
1848
|
onSessionGracePeriodElapsed: () => {
|
|
1747
1849
|
this.onSessionGracePeriodElapsed(connectingSession);
|
|
1850
|
+
},
|
|
1851
|
+
onMessageSendFailure: (msg, reason) => {
|
|
1852
|
+
this.log?.error(`failed to send message: ${reason}`, {
|
|
1853
|
+
...connectingSession.loggingMetadata,
|
|
1854
|
+
transportMessage: msg
|
|
1855
|
+
});
|
|
1856
|
+
this.protocolError({
|
|
1857
|
+
type: ProtocolError.MessageSendFailure,
|
|
1858
|
+
message: reason
|
|
1859
|
+
});
|
|
1860
|
+
this.deleteSession(connectingSession, { unhealthy: true });
|
|
1748
1861
|
}
|
|
1749
1862
|
}
|
|
1750
1863
|
);
|
|
@@ -2075,6 +2188,17 @@ var ServerTransport = class extends Transport {
|
|
|
2075
2188
|
{
|
|
2076
2189
|
onSessionGracePeriodElapsed: () => {
|
|
2077
2190
|
this.onSessionGracePeriodElapsed(noConnectionSession);
|
|
2191
|
+
},
|
|
2192
|
+
onMessageSendFailure: (msg2, reason) => {
|
|
2193
|
+
this.log?.error(`failed to send message: ${reason}`, {
|
|
2194
|
+
...noConnectionSession.loggingMetadata,
|
|
2195
|
+
transportMessage: msg2
|
|
2196
|
+
});
|
|
2197
|
+
this.protocolError({
|
|
2198
|
+
type: ProtocolError.MessageSendFailure,
|
|
2199
|
+
message: reason
|
|
2200
|
+
});
|
|
2201
|
+
this.deleteSession(noConnectionSession, { unhealthy: true });
|
|
2078
2202
|
}
|
|
2079
2203
|
}
|
|
2080
2204
|
);
|
|
@@ -2345,4 +2469,4 @@ export {
|
|
|
2345
2469
|
WebSocketConnection,
|
|
2346
2470
|
CodecMessageAdapter
|
|
2347
2471
|
};
|
|
2348
|
-
//# sourceMappingURL=chunk-
|
|
2472
|
+
//# sourceMappingURL=chunk-VXRAFUA3.js.map
|