@replit/river 0.26.4 → 0.26.6

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 (58) hide show
  1. package/dist/{chunk-RSCUADHY.js → chunk-3NZ73HXL.js} +12 -7
  2. package/dist/chunk-3NZ73HXL.js.map +1 -0
  3. package/dist/{chunk-CYD6GTCU.js → chunk-5INVLQT5.js} +2 -2
  4. package/dist/{chunk-CYD6GTCU.js.map → chunk-5INVLQT5.js.map} +1 -1
  5. package/dist/{chunk-PXRKBNWN.js → chunk-APGOIQC4.js} +2 -2
  6. package/dist/{chunk-HPOR6FST.js → chunk-CER7XNCN.js} +13 -10
  7. package/dist/chunk-CER7XNCN.js.map +1 -0
  8. package/dist/{chunk-65EMTMCV.js → chunk-H2RVJ32Z.js} +4 -9
  9. package/dist/chunk-H2RVJ32Z.js.map +1 -0
  10. package/dist/{chunk-42SXIIHP.js → chunk-H677UET6.js} +20 -12
  11. package/dist/chunk-H677UET6.js.map +1 -0
  12. package/dist/{chunk-DS5LF6PS.js → chunk-J7AQMYUQ.js} +9 -9
  13. package/dist/chunk-J7AQMYUQ.js.map +1 -0
  14. package/dist/{chunk-TAH2GVTJ.js → chunk-MZM234IB.js} +1 -1
  15. package/dist/chunk-MZM234IB.js.map +1 -0
  16. package/dist/{client-6c67339a.d.ts → client-96810511.d.ts} +2 -2
  17. package/dist/{connection-03ffb583.d.ts → connection-48133ec3.d.ts} +1 -1
  18. package/dist/{handshake-154a0bb2.d.ts → handshake-65e0e848.d.ts} +8 -3
  19. package/dist/logging/index.cjs.map +1 -1
  20. package/dist/logging/index.d.cts +1 -1
  21. package/dist/logging/index.d.ts +1 -1
  22. package/dist/logging/index.js +1 -1
  23. package/dist/{message-ff78a233.d.ts → message-e917ee98.d.ts} +1 -1
  24. package/dist/router/index.cjs +3 -8
  25. package/dist/router/index.cjs.map +1 -1
  26. package/dist/router/index.d.cts +8 -8
  27. package/dist/router/index.d.ts +8 -8
  28. package/dist/router/index.js +2 -2
  29. package/dist/{server-1f5eb427.d.ts → server-b8aaf116.d.ts} +3 -3
  30. package/dist/{services-6140f578.d.ts → services-40e7c5cf.d.ts} +3 -3
  31. package/dist/transport/impls/ws/client.cjs +38 -27
  32. package/dist/transport/impls/ws/client.cjs.map +1 -1
  33. package/dist/transport/impls/ws/client.d.cts +4 -4
  34. package/dist/transport/impls/ws/client.d.ts +4 -4
  35. package/dist/transport/impls/ws/client.js +6 -6
  36. package/dist/transport/impls/ws/server.cjs +34 -26
  37. package/dist/transport/impls/ws/server.cjs.map +1 -1
  38. package/dist/transport/impls/ws/server.d.cts +4 -4
  39. package/dist/transport/impls/ws/server.d.ts +4 -4
  40. package/dist/transport/impls/ws/server.js +6 -6
  41. package/dist/transport/index.cjs +43 -32
  42. package/dist/transport/index.cjs.map +1 -1
  43. package/dist/transport/index.d.cts +4 -4
  44. package/dist/transport/index.d.ts +4 -4
  45. package/dist/transport/index.js +6 -6
  46. package/dist/util/testHelpers.cjs +21 -18
  47. package/dist/util/testHelpers.cjs.map +1 -1
  48. package/dist/util/testHelpers.d.cts +4 -4
  49. package/dist/util/testHelpers.d.ts +4 -4
  50. package/dist/util/testHelpers.js +3 -3
  51. package/package.json +1 -1
  52. package/dist/chunk-42SXIIHP.js.map +0 -1
  53. package/dist/chunk-65EMTMCV.js.map +0 -1
  54. package/dist/chunk-DS5LF6PS.js.map +0 -1
  55. package/dist/chunk-HPOR6FST.js.map +0 -1
  56. package/dist/chunk-RSCUADHY.js.map +0 -1
  57. package/dist/chunk-TAH2GVTJ.js.map +0 -1
  58. /package/dist/{chunk-PXRKBNWN.js.map → chunk-APGOIQC4.js.map} +0 -0
@@ -1,7 +1,7 @@
1
- import { C as ClientTransport } from '../../../client-6c67339a.js';
2
- import { c as TransportClientId } from '../../../message-ff78a233.js';
3
- import { b as ProvidedClientTransportOptions } from '../../../handshake-154a0bb2.js';
4
- import { W as WebSocketConnection } from '../../../connection-03ffb583.js';
1
+ import { C as ClientTransport } from '../../../client-96810511.js';
2
+ import { c as TransportClientId } from '../../../message-e917ee98.js';
3
+ import { b as ProvidedClientTransportOptions } from '../../../handshake-65e0e848.js';
4
+ import { W as WebSocketConnection } from '../../../connection-48133ec3.js';
5
5
  import { W as WsLike } from '../../../wslike-e0b32dd5.js';
6
6
  import '@sinclair/typebox/value';
7
7
  import '@sinclair/typebox';
@@ -1,7 +1,7 @@
1
- import { C as ClientTransport } from '../../../client-6c67339a.js';
2
- import { c as TransportClientId } from '../../../message-ff78a233.js';
3
- import { b as ProvidedClientTransportOptions } from '../../../handshake-154a0bb2.js';
4
- import { W as WebSocketConnection } from '../../../connection-03ffb583.js';
1
+ import { C as ClientTransport } from '../../../client-96810511.js';
2
+ import { c as TransportClientId } from '../../../message-e917ee98.js';
3
+ import { b as ProvidedClientTransportOptions } from '../../../handshake-65e0e848.js';
4
+ import { W as WebSocketConnection } from '../../../connection-48133ec3.js';
5
5
  import { W as WsLike } from '../../../wslike-e0b32dd5.js';
6
6
  import '@sinclair/typebox/value';
7
7
  import '@sinclair/typebox';
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  ClientTransport
3
- } from "../../../chunk-HPOR6FST.js";
3
+ } from "../../../chunk-CER7XNCN.js";
4
4
  import {
5
5
  WebSocketConnection
6
- } from "../../../chunk-CYD6GTCU.js";
7
- import "../../../chunk-RSCUADHY.js";
8
- import "../../../chunk-TAH2GVTJ.js";
9
- import "../../../chunk-42SXIIHP.js";
10
- import "../../../chunk-65EMTMCV.js";
6
+ } from "../../../chunk-5INVLQT5.js";
7
+ import "../../../chunk-3NZ73HXL.js";
8
+ import "../../../chunk-MZM234IB.js";
9
+ import "../../../chunk-H677UET6.js";
10
+ import "../../../chunk-H2RVJ32Z.js";
11
11
  import "../../../chunk-4PVU7J25.js";
12
12
 
13
13
  // transport/impls/ws/client.ts
@@ -186,10 +186,7 @@ var ControlMessageHandshakeRequestSchema = import_typebox.Type.Object({
186
186
  expectedSessionState: import_typebox.Type.Object({
187
187
  // what the client expects the server to send next
188
188
  nextExpectedSeq: import_typebox.Type.Integer(),
189
- // TODO: remove optional once we know all servers
190
- // are nextSentSeq here
191
- // what the server expects the client to send next
192
- nextSentSeq: import_typebox.Type.Optional(import_typebox.Type.Integer())
189
+ nextSentSeq: import_typebox.Type.Integer()
193
190
  }),
194
191
  metadata: import_typebox.Type.Optional(import_typebox.Type.Unknown())
195
192
  });
@@ -225,9 +222,7 @@ var ControlMessageHandshakeResponseSchema = import_typebox.Type.Object({
225
222
  import_typebox.Type.Object({
226
223
  ok: import_typebox.Type.Literal(false),
227
224
  reason: import_typebox.Type.String(),
228
- // TODO: remove optional once we know all servers
229
- // are sending code here
230
- code: import_typebox.Type.Optional(HandshakeErrorResponseCodes)
225
+ code: HandshakeErrorResponseCodes
231
226
  })
232
227
  ])
233
228
  });
@@ -397,7 +392,8 @@ var createLogProxy = (log) => ({
397
392
  var ProtocolError = {
398
393
  RetriesExceeded: "conn_retry_exceeded",
399
394
  HandshakeFailed: "handshake_failed",
400
- MessageOrderingViolated: "message_ordering_violated"
395
+ MessageOrderingViolated: "message_ordering_violated",
396
+ InvalidMessage: "invalid_message"
401
397
  };
402
398
  var EventDispatcher = class {
403
399
  eventListeners = {};
@@ -673,7 +669,7 @@ var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
673
669
  var import_api = require("@opentelemetry/api");
674
670
 
675
671
  // package.json
676
- var version = "0.26.4";
672
+ var version = "0.26.6";
677
673
 
678
674
  // tracing/index.ts
679
675
  function createSessionTelemetryInfo(sessionId, to, from, propagationCtx) {
@@ -826,13 +822,13 @@ var SessionConnected = class extends IdentifiedSession {
826
822
  this.conn.addCloseListener(this.listeners.onConnectionClosed);
827
823
  this.conn.addErrorListener(this.listeners.onConnectionErrored);
828
824
  if (this.sendBuffer.length > 0) {
829
- this.log?.debug(
830
- `sending ${this.sendBuffer.length} buffered messages`,
825
+ this.log?.info(
826
+ `sending ${this.sendBuffer.length} buffered messages, starting at seq ${this.nextSeq()}`,
831
827
  this.loggingMetadata
832
828
  );
833
- }
834
- for (const msg of this.sendBuffer) {
835
- this.conn.send(this.options.codec.toBuffer(msg));
829
+ for (const msg of this.sendBuffer) {
830
+ this.conn.send(this.options.codec.toBuffer(msg));
831
+ }
836
832
  }
837
833
  this.isActivelyHeartbeating = false;
838
834
  this.heartbeatHandle = setInterval(() => {
@@ -874,6 +870,12 @@ var SessionConnected = class extends IdentifiedSession {
874
870
  }
875
871
  });
876
872
  }
873
+ closeConnection() {
874
+ this.conn.removeDataListener(this.onMessageData);
875
+ this.conn.removeCloseListener(this.listeners.onConnectionClosed);
876
+ this.conn.removeErrorListener(this.listeners.onConnectionErrored);
877
+ this.conn.close();
878
+ }
877
879
  onMessageData = (msg) => {
878
880
  const parsedMsg = this.parseMsg(msg);
879
881
  if (parsedMsg === null) {
@@ -890,8 +892,8 @@ var SessionConnected = class extends IdentifiedSession {
890
892
  }
891
893
  );
892
894
  } else {
893
- const reason = `received out-of-order msg (got seq: ${parsedMsg.seq}, wanted seq: ${this.ack})`;
894
- this.log?.error(reason, {
895
+ const reason = `received out-of-order msg, closing connection (got seq: ${parsedMsg.seq}, wanted seq: ${this.ack})`;
896
+ this.log?.warn(reason, {
895
897
  ...this.loggingMetadata,
896
898
  transportMessage: parsedMsg,
897
899
  tags: ["invariant-violation"]
@@ -900,7 +902,7 @@ var SessionConnected = class extends IdentifiedSession {
900
902
  code: import_api2.SpanStatusCode.ERROR,
901
903
  message: reason
902
904
  });
903
- this.listeners.onInvalidMessage(reason);
905
+ this.closeConnection();
904
906
  }
905
907
  return;
906
908
  }
@@ -926,8 +928,10 @@ var SessionConnected = class extends IdentifiedSession {
926
928
  this.conn.removeDataListener(this.onMessageData);
927
929
  this.conn.removeCloseListener(this.listeners.onConnectionClosed);
928
930
  this.conn.removeErrorListener(this.listeners.onConnectionErrored);
929
- clearInterval(this.heartbeatHandle);
930
- this.heartbeatHandle = void 0;
931
+ if (this.heartbeatHandle) {
932
+ clearInterval(this.heartbeatHandle);
933
+ this.heartbeatHandle = void 0;
934
+ }
931
935
  }
932
936
  _handleClose() {
933
937
  super._handleClose();
@@ -1356,8 +1360,12 @@ var Transport = class {
1356
1360
  return session;
1357
1361
  }
1358
1362
  // state transitions
1359
- deleteSession(session) {
1360
- session.log?.info(`closing session ${session.id}`, session.loggingMetadata);
1363
+ deleteSession(session, options) {
1364
+ const loggingMetadata = session.loggingMetadata;
1365
+ if (loggingMetadata.tags && options?.unhealthy) {
1366
+ loggingMetadata.tags.push("unhealthy-session");
1367
+ }
1368
+ session.log?.info(`closing session ${session.id}`, loggingMetadata);
1361
1369
  this.eventDispatcher.dispatchEvent("sessionStatus", {
1362
1370
  status: "disconnect",
1363
1371
  session
@@ -1467,9 +1475,9 @@ var ServerTransport = class extends Transport {
1467
1475
  pendingSession.close();
1468
1476
  this.pendingSessions.delete(pendingSession);
1469
1477
  }
1470
- deleteSession(session) {
1478
+ deleteSession(session, options) {
1471
1479
  this.sessionHandshakeMetadata.delete(session.to);
1472
- super.deleteSession(session);
1480
+ super.deleteSession(session, options);
1473
1481
  }
1474
1482
  handleConnection(conn) {
1475
1483
  if (this.getStatus() !== "open")
@@ -1647,7 +1655,7 @@ var ServerTransport = class extends Transport {
1647
1655
  }
1648
1656
  let connectCase = "new session";
1649
1657
  const clientNextExpectedSeq = msg.payload.expectedSessionState.nextExpectedSeq;
1650
- const clientNextSentSeq = msg.payload.expectedSessionState.nextSentSeq ?? 0;
1658
+ const clientNextSentSeq = msg.payload.expectedSessionState.nextSentSeq;
1651
1659
  if (this.options.enableTransparentSessionReconnects && oldSession && oldSession.id === msg.payload.sessionId) {
1652
1660
  connectCase = "transparent reconnection";
1653
1661
  const ourNextSeq = oldSession.nextSeq();
@@ -1763,10 +1771,10 @@ var ServerTransport = class extends Transport {
1763
1771
  onMessage: (msg2) => this.handleMsg(msg2),
1764
1772
  onInvalidMessage: (reason) => {
1765
1773
  this.protocolError({
1766
- type: ProtocolError.MessageOrderingViolated,
1774
+ type: ProtocolError.InvalidMessage,
1767
1775
  message: reason
1768
1776
  });
1769
- this.deleteSession(connectedSession);
1777
+ this.deleteSession(connectedSession, { unhealthy: true });
1770
1778
  }
1771
1779
  }
1772
1780
  );