@replit/river 0.205.1 → 0.205.2

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.
Files changed (43) hide show
  1. package/dist/{chunk-HNBYBRJ7.js → chunk-BYA34LH3.js} +2 -2
  2. package/dist/{chunk-HNBYBRJ7.js.map → chunk-BYA34LH3.js.map} +1 -1
  3. package/dist/{chunk-356UADV3.js → chunk-FCN2JPOE.js} +2 -2
  4. package/dist/{chunk-Y2N4EJYG.js → chunk-FTOB2HQN.js} +39 -6
  5. package/dist/chunk-FTOB2HQN.js.map +1 -0
  6. package/dist/{chunk-OVLZDQF4.js → chunk-TP4OJAKI.js} +4 -4
  7. package/dist/{chunk-OVLZDQF4.js.map → chunk-TP4OJAKI.js.map} +1 -1
  8. package/dist/{chunk-3XCLUGDM.js → chunk-W337YQLT.js} +3 -3
  9. package/dist/{client-c44d1c69.d.ts → client-8ab60722.d.ts} +1 -1
  10. package/dist/{connection-03726441.d.ts → connection-8ed39cb5.d.ts} +1 -1
  11. package/dist/{context-ebf88958.d.ts → context-2c4bb66b.d.ts} +11 -0
  12. package/dist/router/index.cjs +1 -1
  13. package/dist/router/index.cjs.map +1 -1
  14. package/dist/router/index.d.cts +7 -7
  15. package/dist/router/index.d.ts +7 -7
  16. package/dist/router/index.js +1 -1
  17. package/dist/{server-b169b234.d.ts → server-dc261419.d.ts} +1 -1
  18. package/dist/{services-47b312aa.d.ts → services-036dcc97.d.ts} +2 -2
  19. package/dist/testUtil/index.cjs +43 -7
  20. package/dist/testUtil/index.cjs.map +1 -1
  21. package/dist/testUtil/index.d.cts +4 -4
  22. package/dist/testUtil/index.d.ts +4 -4
  23. package/dist/testUtil/index.js +8 -5
  24. package/dist/testUtil/index.js.map +1 -1
  25. package/dist/transport/impls/ws/client.cjs +38 -5
  26. package/dist/transport/impls/ws/client.cjs.map +1 -1
  27. package/dist/transport/impls/ws/client.d.cts +3 -3
  28. package/dist/transport/impls/ws/client.d.ts +3 -3
  29. package/dist/transport/impls/ws/client.js +4 -4
  30. package/dist/transport/impls/ws/server.cjs +39 -6
  31. package/dist/transport/impls/ws/server.cjs.map +1 -1
  32. package/dist/transport/impls/ws/server.d.cts +3 -3
  33. package/dist/transport/impls/ws/server.d.ts +3 -3
  34. package/dist/transport/impls/ws/server.js +4 -4
  35. package/dist/transport/index.cjs +39 -6
  36. package/dist/transport/index.cjs.map +1 -1
  37. package/dist/transport/index.d.cts +3 -3
  38. package/dist/transport/index.d.ts +3 -3
  39. package/dist/transport/index.js +4 -4
  40. package/package.json +4 -4
  41. package/dist/chunk-Y2N4EJYG.js.map +0 -1
  42. /package/dist/{chunk-356UADV3.js.map → chunk-FCN2JPOE.js.map} +0 -0
  43. /package/dist/{chunk-3XCLUGDM.js.map → chunk-W337YQLT.js.map} +0 -0
@@ -1,7 +1,7 @@
1
- import { C as ClientTransport } from '../../../client-c44d1c69.js';
1
+ import { C as ClientTransport } from '../../../client-8ab60722.js';
2
2
  import { c as TransportClientId } from '../../../message-865bba35.js';
3
- import { b as ProvidedClientTransportOptions } from '../../../context-ebf88958.js';
4
- import { W as WebSocketConnection } from '../../../connection-03726441.js';
3
+ import { b as ProvidedClientTransportOptions } from '../../../context-2c4bb66b.js';
4
+ import { W as WebSocketConnection } from '../../../connection-8ed39cb5.js';
5
5
  import { W as WsLike } from '../../../wslike-e0b32dd5.js';
6
6
  import '@sinclair/typebox';
7
7
  import '@opentelemetry/api';
@@ -1,7 +1,7 @@
1
- import { C as ClientTransport } from '../../../client-c44d1c69.js';
1
+ import { C as ClientTransport } from '../../../client-8ab60722.js';
2
2
  import { c as TransportClientId } from '../../../message-865bba35.js';
3
- import { b as ProvidedClientTransportOptions } from '../../../context-ebf88958.js';
4
- import { W as WebSocketConnection } from '../../../connection-03726441.js';
3
+ import { b as ProvidedClientTransportOptions } from '../../../context-2c4bb66b.js';
4
+ import { W as WebSocketConnection } from '../../../connection-8ed39cb5.js';
5
5
  import { W as WsLike } from '../../../wslike-e0b32dd5.js';
6
6
  import '@sinclair/typebox';
7
7
  import '@opentelemetry/api';
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  ClientTransport
3
- } from "../../../chunk-3XCLUGDM.js";
3
+ } from "../../../chunk-W337YQLT.js";
4
4
  import {
5
5
  WebSocketConnection
6
- } from "../../../chunk-356UADV3.js";
7
- import "../../../chunk-Y2N4EJYG.js";
8
- import "../../../chunk-HNBYBRJ7.js";
6
+ } from "../../../chunk-FCN2JPOE.js";
7
+ import "../../../chunk-FTOB2HQN.js";
8
+ import "../../../chunk-BYA34LH3.js";
9
9
  import "../../../chunk-CC7RN7GI.js";
10
10
  import "../../../chunk-AJGIY2UB.js";
11
11
 
@@ -560,13 +560,27 @@ var IdentifiedSession = class extends CommonSession {
560
560
  * Index of the message we will send next (excluding handshake)
561
561
  */
562
562
  seq;
563
+ /**
564
+ * Last seq we sent over the wire this session (excluding handshake) and retransmissions
565
+ */
566
+ seqSent;
563
567
  /**
564
568
  * Number of unique messages we've received this session (excluding handshake)
565
569
  */
566
570
  ack;
567
571
  sendBuffer;
568
572
  constructor(props) {
569
- const { id, to, seq, ack, sendBuffer, telemetry, log, protocolVersion } = props;
573
+ const {
574
+ id,
575
+ to,
576
+ seq,
577
+ ack,
578
+ sendBuffer,
579
+ telemetry,
580
+ log,
581
+ protocolVersion,
582
+ seqSent: messagesSent
583
+ } = props;
570
584
  super(props);
571
585
  this.id = id;
572
586
  this.to = to;
@@ -576,6 +590,7 @@ var IdentifiedSession = class extends CommonSession {
576
590
  this.telemetry = telemetry;
577
591
  this.log = log;
578
592
  this.protocolVersion = protocolVersion;
593
+ this.seqSent = messagesSent;
579
594
  }
580
595
  get loggingMetadata() {
581
596
  const metadata = {
@@ -722,7 +737,7 @@ function coerceErrorString(err) {
722
737
  }
723
738
 
724
739
  // package.json
725
- var version = "0.205.1";
740
+ var version = "0.205.2";
726
741
 
727
742
  // tracing/index.ts
728
743
  function createSessionTelemetryInfo(tracer, sessionId, to, from, propagationCtx) {
@@ -878,10 +893,23 @@ var SessionConnected = class extends IdentifiedSession {
878
893
  this.ack = seq + 1;
879
894
  this.heartbeatMisses = 0;
880
895
  }
896
+ assertSendOrdering(constructedMsg) {
897
+ if (constructedMsg.seq > this.seqSent + 1) {
898
+ const msg = `invariant violation: would have sent out of order msg (seq: ${constructedMsg.seq}, expected: ${this.seqSent} + 1)`;
899
+ this.log?.error(msg, {
900
+ ...this.loggingMetadata,
901
+ transportMessage: constructedMsg,
902
+ tags: ["invariant-violation"]
903
+ });
904
+ throw new Error(msg);
905
+ }
906
+ }
881
907
  send(msg) {
882
908
  const constructedMsg = this.constructMsg(msg);
909
+ this.assertSendOrdering(constructedMsg);
883
910
  this.sendBuffer.push(constructedMsg);
884
911
  this.conn.send(this.options.codec.toBuffer(constructedMsg));
912
+ this.seqSent = constructedMsg.seq;
885
913
  return constructedMsg.id;
886
914
  }
887
915
  constructor(props) {
@@ -897,7 +925,9 @@ var SessionConnected = class extends IdentifiedSession {
897
925
  this.loggingMetadata
898
926
  );
899
927
  for (const msg of this.sendBuffer) {
928
+ this.assertSendOrdering(msg);
900
929
  this.conn.send(this.options.codec.toBuffer(msg));
930
+ this.seqSent = msg.seq;
901
931
  }
902
932
  }
903
933
  this.isActivelyHeartbeating = false;
@@ -963,7 +993,7 @@ var SessionConnected = class extends IdentifiedSession {
963
993
  );
964
994
  } else {
965
995
  const reason = `received out-of-order msg, closing connection (got seq: ${parsedMsg.seq}, wanted seq: ${this.ack})`;
966
- this.log?.warn(reason, {
996
+ this.log?.error(reason, {
967
997
  ...this.loggingMetadata,
968
998
  transportMessage: parsedMsg,
969
999
  tags: ["invariant-violation"]
@@ -1041,6 +1071,7 @@ function inheritSharedSession(session) {
1041
1071
  to: session.to,
1042
1072
  seq: session.seq,
1043
1073
  ack: session.ack,
1074
+ seqSent: session.seqSent,
1044
1075
  sendBuffer: session.sendBuffer,
1045
1076
  telemetry: session.telemetry,
1046
1077
  options: session.options,
@@ -1068,6 +1099,7 @@ var SessionStateGraph = {
1068
1099
  to,
1069
1100
  seq: 0,
1070
1101
  ack: 0,
1102
+ seqSent: 0,
1071
1103
  graceExpiryTime: Date.now() + options.sessionDisconnectGraceMs,
1072
1104
  sendBuffer,
1073
1105
  telemetry,
@@ -1190,6 +1222,7 @@ var SessionStateGraph = {
1190
1222
  to,
1191
1223
  seq: 0,
1192
1224
  ack: 0,
1225
+ seqSent: 0,
1193
1226
  sendBuffer: [],
1194
1227
  telemetry: createSessionTelemetryInfo(
1195
1228
  pendingSession.tracer,
@@ -1449,7 +1482,7 @@ var Transport = class {
1449
1482
  });
1450
1483
  this.eventDispatcher.dispatchEvent("sessionTransition", {
1451
1484
  state: session.state,
1452
- session
1485
+ id: session.id
1453
1486
  });
1454
1487
  }
1455
1488
  updateSession(session) {
@@ -1473,7 +1506,7 @@ var Transport = class {
1473
1506
  this.sessions.set(session.to, session);
1474
1507
  this.eventDispatcher.dispatchEvent("sessionTransition", {
1475
1508
  state: session.state,
1476
- session
1509
+ id: session.id
1477
1510
  });
1478
1511
  }
1479
1512
  deleteSession(session, options) {
@@ -1823,8 +1856,8 @@ var ServerTransport = class extends Transport {
1823
1856
  }
1824
1857
  );
1825
1858
  oldSession = noConnectionSession;
1859
+ this.updateSession(oldSession);
1826
1860
  }
1827
- this.updateSession(oldSession);
1828
1861
  } else if (oldSession) {
1829
1862
  connectCase = "hard reconnection";
1830
1863
  this.log?.info(