@replit/river 0.205.0 → 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 (52) hide show
  1. package/dist/{chunk-GG3GL7CW.js → chunk-BYA34LH3.js} +41 -13
  2. package/dist/chunk-BYA34LH3.js.map +1 -0
  3. package/dist/{chunk-WBGKPIFS.js → chunk-CC7RN7GI.js} +1 -1
  4. package/dist/chunk-CC7RN7GI.js.map +1 -0
  5. package/dist/{chunk-EU2H4J7U.js → chunk-FCN2JPOE.js} +2 -2
  6. package/dist/{chunk-AXZPYUY6.js → chunk-FTOB2HQN.js} +40 -7
  7. package/dist/chunk-FTOB2HQN.js.map +1 -0
  8. package/dist/{chunk-VN7QS6OS.js → chunk-TP4OJAKI.js} +4 -4
  9. package/dist/{chunk-VN7QS6OS.js.map → chunk-TP4OJAKI.js.map} +1 -1
  10. package/dist/{chunk-RAO6UI45.js → chunk-W337YQLT.js} +3 -3
  11. package/dist/{client-3adfb12a.d.ts → client-8ab60722.d.ts} +2 -2
  12. package/dist/{connection-9ca3e7ed.d.ts → connection-8ed39cb5.d.ts} +6 -4
  13. package/dist/{context-1a332293.d.ts → context-2c4bb66b.d.ts} +20 -4
  14. package/dist/logging/index.cjs.map +1 -1
  15. package/dist/logging/index.d.cts +1 -2
  16. package/dist/logging/index.d.ts +1 -2
  17. package/dist/logging/index.js +1 -1
  18. package/dist/{message-3def9ded.d.ts → message-865bba35.d.ts} +4 -2
  19. package/dist/router/index.cjs +40 -12
  20. package/dist/router/index.cjs.map +1 -1
  21. package/dist/router/index.d.cts +8 -10
  22. package/dist/router/index.d.ts +8 -10
  23. package/dist/router/index.js +1 -1
  24. package/dist/{server-8ac5c6bf.d.ts → server-dc261419.d.ts} +6 -4
  25. package/dist/{services-4213d92e.d.ts → services-036dcc97.d.ts} +11 -3
  26. package/dist/testUtil/index.cjs +43 -7
  27. package/dist/testUtil/index.cjs.map +1 -1
  28. package/dist/testUtil/index.d.cts +5 -7
  29. package/dist/testUtil/index.d.ts +5 -7
  30. package/dist/testUtil/index.js +9 -6
  31. package/dist/testUtil/index.js.map +1 -1
  32. package/dist/transport/impls/ws/client.cjs +38 -5
  33. package/dist/transport/impls/ws/client.cjs.map +1 -1
  34. package/dist/transport/impls/ws/client.d.cts +4 -6
  35. package/dist/transport/impls/ws/client.d.ts +4 -6
  36. package/dist/transport/impls/ws/client.js +5 -5
  37. package/dist/transport/impls/ws/server.cjs +39 -6
  38. package/dist/transport/impls/ws/server.cjs.map +1 -1
  39. package/dist/transport/impls/ws/server.d.cts +4 -6
  40. package/dist/transport/impls/ws/server.d.ts +4 -6
  41. package/dist/transport/impls/ws/server.js +5 -5
  42. package/dist/transport/index.cjs +39 -6
  43. package/dist/transport/index.cjs.map +1 -1
  44. package/dist/transport/index.d.cts +4 -6
  45. package/dist/transport/index.d.ts +4 -6
  46. package/dist/transport/index.js +5 -5
  47. package/package.json +4 -4
  48. package/dist/chunk-AXZPYUY6.js.map +0 -1
  49. package/dist/chunk-GG3GL7CW.js.map +0 -1
  50. package/dist/chunk-WBGKPIFS.js.map +0 -1
  51. /package/dist/{chunk-EU2H4J7U.js.map → chunk-FCN2JPOE.js.map} +0 -0
  52. /package/dist/{chunk-RAO6UI45.js.map → chunk-W337YQLT.js.map} +0 -0
@@ -1,14 +1,12 @@
1
- import { c as TransportClientId } from '../../../message-3def9ded.js';
1
+ import { c as TransportClientId } from '../../../message-865bba35.js';
2
2
  import { WebSocketServer } from 'ws';
3
- import { W as WebSocketConnection } from '../../../connection-9ca3e7ed.js';
3
+ import { W as WebSocketConnection } from '../../../connection-8ed39cb5.js';
4
4
  import { W as WsLike } from '../../../wslike-e0b32dd5.js';
5
- import { S as ServerTransport } from '../../../server-8ac5c6bf.js';
6
- import { c as ProvidedServerTransportOptions } from '../../../context-1a332293.js';
5
+ import { S as ServerTransport } from '../../../server-dc261419.js';
6
+ import { c as ProvidedServerTransportOptions } from '../../../context-2c4bb66b.js';
7
7
  import { IncomingMessage } from 'http';
8
- import '@sinclair/typebox/value';
9
8
  import '@sinclair/typebox';
10
9
  import '@opentelemetry/api';
11
- import '@sinclair/typebox/errors';
12
10
  import '../../../types-3e5768ec.js';
13
11
 
14
12
  declare class WebSocketServerTransport extends ServerTransport<WebSocketConnection> {
@@ -1,14 +1,12 @@
1
- import { c as TransportClientId } from '../../../message-3def9ded.js';
1
+ import { c as TransportClientId } from '../../../message-865bba35.js';
2
2
  import { WebSocketServer } from 'ws';
3
- import { W as WebSocketConnection } from '../../../connection-9ca3e7ed.js';
3
+ import { W as WebSocketConnection } from '../../../connection-8ed39cb5.js';
4
4
  import { W as WsLike } from '../../../wslike-e0b32dd5.js';
5
- import { S as ServerTransport } from '../../../server-8ac5c6bf.js';
6
- import { c as ProvidedServerTransportOptions } from '../../../context-1a332293.js';
5
+ import { S as ServerTransport } from '../../../server-dc261419.js';
6
+ import { c as ProvidedServerTransportOptions } from '../../../context-2c4bb66b.js';
7
7
  import { IncomingMessage } from 'http';
8
- import '@sinclair/typebox/value';
9
8
  import '@sinclair/typebox';
10
9
  import '@opentelemetry/api';
11
- import '@sinclair/typebox/errors';
12
10
  import '../../../types-3e5768ec.js';
13
11
 
14
12
  declare class WebSocketServerTransport extends ServerTransport<WebSocketConnection> {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  ServerTransport
3
- } from "../../../chunk-VN7QS6OS.js";
3
+ } from "../../../chunk-TP4OJAKI.js";
4
4
  import {
5
5
  WebSocketConnection
6
- } from "../../../chunk-EU2H4J7U.js";
7
- import "../../../chunk-AXZPYUY6.js";
8
- import "../../../chunk-GG3GL7CW.js";
9
- import "../../../chunk-WBGKPIFS.js";
6
+ } from "../../../chunk-FCN2JPOE.js";
7
+ import "../../../chunk-FTOB2HQN.js";
8
+ import "../../../chunk-BYA34LH3.js";
9
+ import "../../../chunk-CC7RN7GI.js";
10
10
  import "../../../chunk-AJGIY2UB.js";
11
11
 
12
12
  // transport/impls/ws/server.ts
@@ -468,13 +468,27 @@ var IdentifiedSession = class extends CommonSession {
468
468
  * Index of the message we will send next (excluding handshake)
469
469
  */
470
470
  seq;
471
+ /**
472
+ * Last seq we sent over the wire this session (excluding handshake) and retransmissions
473
+ */
474
+ seqSent;
471
475
  /**
472
476
  * Number of unique messages we've received this session (excluding handshake)
473
477
  */
474
478
  ack;
475
479
  sendBuffer;
476
480
  constructor(props) {
477
- const { id, to, seq, ack, sendBuffer, telemetry, log, protocolVersion } = props;
481
+ const {
482
+ id,
483
+ to,
484
+ seq,
485
+ ack,
486
+ sendBuffer,
487
+ telemetry,
488
+ log,
489
+ protocolVersion,
490
+ seqSent: messagesSent
491
+ } = props;
478
492
  super(props);
479
493
  this.id = id;
480
494
  this.to = to;
@@ -484,6 +498,7 @@ var IdentifiedSession = class extends CommonSession {
484
498
  this.telemetry = telemetry;
485
499
  this.log = log;
486
500
  this.protocolVersion = protocolVersion;
501
+ this.seqSent = messagesSent;
487
502
  }
488
503
  get loggingMetadata() {
489
504
  const metadata = {
@@ -630,7 +645,7 @@ function coerceErrorString(err) {
630
645
  }
631
646
 
632
647
  // package.json
633
- var version = "0.205.0";
648
+ var version = "0.205.2";
634
649
 
635
650
  // tracing/index.ts
636
651
  function getPropagationContext(ctx) {
@@ -794,10 +809,23 @@ var SessionConnected = class extends IdentifiedSession {
794
809
  this.ack = seq + 1;
795
810
  this.heartbeatMisses = 0;
796
811
  }
812
+ assertSendOrdering(constructedMsg) {
813
+ if (constructedMsg.seq > this.seqSent + 1) {
814
+ const msg = `invariant violation: would have sent out of order msg (seq: ${constructedMsg.seq}, expected: ${this.seqSent} + 1)`;
815
+ this.log?.error(msg, {
816
+ ...this.loggingMetadata,
817
+ transportMessage: constructedMsg,
818
+ tags: ["invariant-violation"]
819
+ });
820
+ throw new Error(msg);
821
+ }
822
+ }
797
823
  send(msg) {
798
824
  const constructedMsg = this.constructMsg(msg);
825
+ this.assertSendOrdering(constructedMsg);
799
826
  this.sendBuffer.push(constructedMsg);
800
827
  this.conn.send(this.options.codec.toBuffer(constructedMsg));
828
+ this.seqSent = constructedMsg.seq;
801
829
  return constructedMsg.id;
802
830
  }
803
831
  constructor(props) {
@@ -813,7 +841,9 @@ var SessionConnected = class extends IdentifiedSession {
813
841
  this.loggingMetadata
814
842
  );
815
843
  for (const msg of this.sendBuffer) {
844
+ this.assertSendOrdering(msg);
816
845
  this.conn.send(this.options.codec.toBuffer(msg));
846
+ this.seqSent = msg.seq;
817
847
  }
818
848
  }
819
849
  this.isActivelyHeartbeating = false;
@@ -879,7 +909,7 @@ var SessionConnected = class extends IdentifiedSession {
879
909
  );
880
910
  } else {
881
911
  const reason = `received out-of-order msg, closing connection (got seq: ${parsedMsg.seq}, wanted seq: ${this.ack})`;
882
- this.log?.warn(reason, {
912
+ this.log?.error(reason, {
883
913
  ...this.loggingMetadata,
884
914
  transportMessage: parsedMsg,
885
915
  tags: ["invariant-violation"]
@@ -957,6 +987,7 @@ function inheritSharedSession(session) {
957
987
  to: session.to,
958
988
  seq: session.seq,
959
989
  ack: session.ack,
990
+ seqSent: session.seqSent,
960
991
  sendBuffer: session.sendBuffer,
961
992
  telemetry: session.telemetry,
962
993
  options: session.options,
@@ -984,6 +1015,7 @@ var SessionStateGraph = {
984
1015
  to,
985
1016
  seq: 0,
986
1017
  ack: 0,
1018
+ seqSent: 0,
987
1019
  graceExpiryTime: Date.now() + options.sessionDisconnectGraceMs,
988
1020
  sendBuffer,
989
1021
  telemetry,
@@ -1106,6 +1138,7 @@ var SessionStateGraph = {
1106
1138
  to,
1107
1139
  seq: 0,
1108
1140
  ack: 0,
1141
+ seqSent: 0,
1109
1142
  sendBuffer: [],
1110
1143
  telemetry: createSessionTelemetryInfo(
1111
1144
  pendingSession.tracer,
@@ -1365,7 +1398,7 @@ var Transport = class {
1365
1398
  });
1366
1399
  this.eventDispatcher.dispatchEvent("sessionTransition", {
1367
1400
  state: session.state,
1368
- session
1401
+ id: session.id
1369
1402
  });
1370
1403
  }
1371
1404
  updateSession(session) {
@@ -1389,7 +1422,7 @@ var Transport = class {
1389
1422
  this.sessions.set(session.to, session);
1390
1423
  this.eventDispatcher.dispatchEvent("sessionTransition", {
1391
1424
  state: session.state,
1392
- session
1425
+ id: session.id
1393
1426
  });
1394
1427
  }
1395
1428
  deleteSession(session, options) {
@@ -2159,8 +2192,8 @@ var ServerTransport = class extends Transport {
2159
2192
  }
2160
2193
  );
2161
2194
  oldSession = noConnectionSession;
2195
+ this.updateSession(oldSession);
2162
2196
  }
2163
- this.updateSession(oldSession);
2164
2197
  } else if (oldSession) {
2165
2198
  connectCase = "hard reconnection";
2166
2199
  this.log?.info(