@replit/river 0.26.5 → 0.26.7

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 (60) hide show
  1. package/dist/{chunk-FA2IRWCM.js → chunk-C7OSTU6D.js} +2 -2
  2. package/dist/{chunk-XRZ52TYH.js → chunk-F32IOMOX.js} +15 -7
  3. package/dist/chunk-F32IOMOX.js.map +1 -0
  4. package/dist/{chunk-IPOUVVKT.js → chunk-I3Z6XQVK.js} +12 -7
  5. package/dist/chunk-I3Z6XQVK.js.map +1 -0
  6. package/dist/{chunk-PZEYFHAB.js → chunk-JJX4ALPO.js} +11 -8
  7. package/dist/chunk-JJX4ALPO.js.map +1 -0
  8. package/dist/{chunk-QEWSUVWV.js → chunk-KMH4I245.js} +12 -3
  9. package/dist/chunk-KMH4I245.js.map +1 -0
  10. package/dist/{chunk-TAH2GVTJ.js → chunk-KTS4HBYE.js} +1 -1
  11. package/dist/chunk-KTS4HBYE.js.map +1 -0
  12. package/dist/{chunk-7KB7DHFZ.js → chunk-NHM3XC6K.js} +2 -2
  13. package/dist/{chunk-7KB7DHFZ.js.map → chunk-NHM3XC6K.js.map} +1 -1
  14. package/dist/{chunk-AZ3ILPXP.js → chunk-X4TDCNNT.js} +8 -8
  15. package/dist/chunk-X4TDCNNT.js.map +1 -0
  16. package/dist/{client-6c67339a.d.ts → client-1229b53d.d.ts} +2 -2
  17. package/dist/connection-c5ffd44e.d.ts +32 -0
  18. package/dist/{handshake-154a0bb2.d.ts → handshake-02a61755.d.ts} +10 -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-3edb8fac.d.ts} +2 -1
  24. package/dist/router/index.cjs +1 -1
  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-89076d9a.d.ts} +4 -3
  30. package/dist/{services-6140f578.d.ts → services-4478e99b.d.ts} +3 -3
  31. package/dist/transport/impls/ws/client.cjs +39 -14
  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 +50 -16
  37. package/dist/transport/impls/ws/server.cjs.map +1 -1
  38. package/dist/transport/impls/ws/server.d.cts +6 -5
  39. package/dist/transport/impls/ws/server.d.ts +6 -5
  40. package/dist/transport/impls/ws/server.js +20 -8
  41. package/dist/transport/impls/ws/server.js.map +1 -1
  42. package/dist/transport/index.cjs +33 -17
  43. package/dist/transport/index.cjs.map +1 -1
  44. package/dist/transport/index.d.cts +4 -4
  45. package/dist/transport/index.d.ts +4 -4
  46. package/dist/transport/index.js +6 -6
  47. package/dist/util/testHelpers.cjs +14 -6
  48. package/dist/util/testHelpers.cjs.map +1 -1
  49. package/dist/util/testHelpers.d.cts +4 -4
  50. package/dist/util/testHelpers.d.ts +4 -4
  51. package/dist/util/testHelpers.js +3 -3
  52. package/package.json +1 -1
  53. package/dist/chunk-AZ3ILPXP.js.map +0 -1
  54. package/dist/chunk-IPOUVVKT.js.map +0 -1
  55. package/dist/chunk-PZEYFHAB.js.map +0 -1
  56. package/dist/chunk-QEWSUVWV.js.map +0 -1
  57. package/dist/chunk-TAH2GVTJ.js.map +0 -1
  58. package/dist/chunk-XRZ52TYH.js.map +0 -1
  59. package/dist/connection-03ffb583.d.ts +0 -11
  60. /package/dist/{chunk-FA2IRWCM.js.map → chunk-C7OSTU6D.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-1229b53d.js';
2
+ import { c as TransportClientId } from '../../../message-3edb8fac.js';
3
+ import { b as ProvidedClientTransportOptions } from '../../../handshake-02a61755.js';
4
+ import { W as WebSocketConnection } from '../../../connection-c5ffd44e.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-1229b53d.js';
2
+ import { c as TransportClientId } from '../../../message-3edb8fac.js';
3
+ import { b as ProvidedClientTransportOptions } from '../../../handshake-02a61755.js';
4
+ import { W as WebSocketConnection } from '../../../connection-c5ffd44e.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-PZEYFHAB.js";
3
+ } from "../../../chunk-JJX4ALPO.js";
4
4
  import {
5
5
  WebSocketConnection
6
- } from "../../../chunk-QEWSUVWV.js";
7
- import "../../../chunk-IPOUVVKT.js";
8
- import "../../../chunk-TAH2GVTJ.js";
9
- import "../../../chunk-XRZ52TYH.js";
10
- import "../../../chunk-7KB7DHFZ.js";
6
+ } from "../../../chunk-KMH4I245.js";
7
+ import "../../../chunk-I3Z6XQVK.js";
8
+ import "../../../chunk-KTS4HBYE.js";
9
+ import "../../../chunk-F32IOMOX.js";
10
+ import "../../../chunk-NHM3XC6K.js";
11
11
  import "../../../chunk-4PVU7J25.js";
12
12
 
13
13
  // transport/impls/ws/client.ts
@@ -105,9 +105,18 @@ var Connection = class {
105
105
  // transport/impls/ws/connection.ts
106
106
  var WebSocketConnection = class extends Connection {
107
107
  ws;
108
- constructor(ws) {
108
+ extras;
109
+ get loggingMetadata() {
110
+ const metadata = super.loggingMetadata;
111
+ if (this.extras) {
112
+ metadata.extras = this.extras;
113
+ }
114
+ return metadata;
115
+ }
116
+ constructor(ws, extras) {
109
117
  super();
110
118
  this.ws = ws;
119
+ this.extras = extras;
111
120
  this.ws.binaryType = "arraybuffer";
112
121
  let didError = false;
113
122
  this.ws.onerror = () => {
@@ -392,7 +401,8 @@ var createLogProxy = (log) => ({
392
401
  var ProtocolError = {
393
402
  RetriesExceeded: "conn_retry_exceeded",
394
403
  HandshakeFailed: "handshake_failed",
395
- MessageOrderingViolated: "message_ordering_violated"
404
+ MessageOrderingViolated: "message_ordering_violated",
405
+ InvalidMessage: "invalid_message"
396
406
  };
397
407
  var EventDispatcher = class {
398
408
  eventListeners = {};
@@ -668,7 +678,7 @@ var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
668
678
  var import_api = require("@opentelemetry/api");
669
679
 
670
680
  // package.json
671
- var version = "0.26.5";
681
+ var version = "0.26.7";
672
682
 
673
683
  // tracing/index.ts
674
684
  function createSessionTelemetryInfo(sessionId, to, from, propagationCtx) {
@@ -869,6 +879,12 @@ var SessionConnected = class extends IdentifiedSession {
869
879
  }
870
880
  });
871
881
  }
882
+ closeConnection() {
883
+ this.conn.removeDataListener(this.onMessageData);
884
+ this.conn.removeCloseListener(this.listeners.onConnectionClosed);
885
+ this.conn.removeErrorListener(this.listeners.onConnectionErrored);
886
+ this.conn.close();
887
+ }
872
888
  onMessageData = (msg) => {
873
889
  const parsedMsg = this.parseMsg(msg);
874
890
  if (parsedMsg === null) {
@@ -885,8 +901,8 @@ var SessionConnected = class extends IdentifiedSession {
885
901
  }
886
902
  );
887
903
  } else {
888
- const reason = `received out-of-order msg (got seq: ${parsedMsg.seq}, wanted seq: ${this.ack})`;
889
- this.log?.error(reason, {
904
+ const reason = `received out-of-order msg, closing connection (got seq: ${parsedMsg.seq}, wanted seq: ${this.ack})`;
905
+ this.log?.warn(reason, {
890
906
  ...this.loggingMetadata,
891
907
  transportMessage: parsedMsg,
892
908
  tags: ["invariant-violation"]
@@ -895,7 +911,7 @@ var SessionConnected = class extends IdentifiedSession {
895
911
  code: import_api2.SpanStatusCode.ERROR,
896
912
  message: reason
897
913
  });
898
- this.listeners.onInvalidMessage(reason);
914
+ this.closeConnection();
899
915
  }
900
916
  return;
901
917
  }
@@ -921,8 +937,10 @@ var SessionConnected = class extends IdentifiedSession {
921
937
  this.conn.removeDataListener(this.onMessageData);
922
938
  this.conn.removeCloseListener(this.listeners.onConnectionClosed);
923
939
  this.conn.removeErrorListener(this.listeners.onConnectionErrored);
924
- clearInterval(this.heartbeatHandle);
925
- this.heartbeatHandle = void 0;
940
+ if (this.heartbeatHandle) {
941
+ clearInterval(this.heartbeatHandle);
942
+ this.heartbeatHandle = void 0;
943
+ }
926
944
  }
927
945
  _handleClose() {
928
946
  super._handleClose();
@@ -1351,8 +1369,12 @@ var Transport = class {
1351
1369
  return session;
1352
1370
  }
1353
1371
  // state transitions
1354
- deleteSession(session) {
1355
- session.log?.info(`closing session ${session.id}`, session.loggingMetadata);
1372
+ deleteSession(session, options) {
1373
+ const loggingMetadata = session.loggingMetadata;
1374
+ if (loggingMetadata.tags && options?.unhealthy) {
1375
+ loggingMetadata.tags.push("unhealthy-session");
1376
+ }
1377
+ session.log?.info(`closing session ${session.id}`, loggingMetadata);
1356
1378
  this.eventDispatcher.dispatchEvent("sessionStatus", {
1357
1379
  status: "disconnect",
1358
1380
  session
@@ -1462,9 +1484,9 @@ var ServerTransport = class extends Transport {
1462
1484
  pendingSession.close();
1463
1485
  this.pendingSessions.delete(pendingSession);
1464
1486
  }
1465
- deleteSession(session) {
1487
+ deleteSession(session, options) {
1466
1488
  this.sessionHandshakeMetadata.delete(session.to);
1467
- super.deleteSession(session);
1489
+ super.deleteSession(session, options);
1468
1490
  }
1469
1491
  handleConnection(conn) {
1470
1492
  if (this.getStatus() !== "open")
@@ -1758,10 +1780,10 @@ var ServerTransport = class extends Transport {
1758
1780
  onMessage: (msg2) => this.handleMsg(msg2),
1759
1781
  onInvalidMessage: (reason) => {
1760
1782
  this.protocolError({
1761
- type: ProtocolError.MessageOrderingViolated,
1783
+ type: ProtocolError.InvalidMessage,
1762
1784
  message: reason
1763
1785
  });
1764
- this.deleteSession(connectedSession);
1786
+ this.deleteSession(connectedSession, { unhealthy: true });
1765
1787
  }
1766
1788
  }
1767
1789
  );
@@ -1773,6 +1795,16 @@ var ServerTransport = class extends Transport {
1773
1795
  };
1774
1796
 
1775
1797
  // transport/impls/ws/server.ts
1798
+ function cleanHeaders(headers) {
1799
+ const cleanedHeaders = {};
1800
+ for (const [key, value] of Object.entries(headers)) {
1801
+ if (!key.startsWith("sec-") && value) {
1802
+ const cleanedValue = Array.isArray(value) ? value[0] : value;
1803
+ cleanedHeaders[key] = cleanedValue;
1804
+ }
1805
+ }
1806
+ return cleanedHeaders;
1807
+ }
1776
1808
  var WebSocketServerTransport = class extends ServerTransport {
1777
1809
  wss;
1778
1810
  constructor(wss, clientId, providedOptions) {
@@ -1780,8 +1812,10 @@ var WebSocketServerTransport = class extends ServerTransport {
1780
1812
  this.wss = wss;
1781
1813
  this.wss.on("connection", this.connectionHandler);
1782
1814
  }
1783
- connectionHandler = (ws) => {
1784
- const conn = new WebSocketConnection(ws);
1815
+ connectionHandler = (ws, req) => {
1816
+ const conn = new WebSocketConnection(ws, {
1817
+ headers: cleanHeaders(req.headersDistinct)
1818
+ });
1785
1819
  this.handleConnection(conn);
1786
1820
  };
1787
1821
  close() {