@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.
Files changed (55) hide show
  1. package/dist/{adapter-Cp7_gIVA.d.ts → adapter-CgF7vQPu.d.ts} +3 -2
  2. package/dist/{adapter-DjiEwOYi.d.cts → adapter-IGrG4KLL.d.cts} +3 -2
  3. package/dist/{chunk-LECVFB2G.js → chunk-RDTQZ7HO.js} +15 -10
  4. package/dist/chunk-RDTQZ7HO.js.map +1 -0
  5. package/dist/{chunk-DRYCLL6N.js → chunk-VXRAFUA3.js} +178 -54
  6. package/dist/chunk-VXRAFUA3.js.map +1 -0
  7. package/dist/{client-Dw0JBBs3.d.ts → client-BhwlY0-L.d.ts} +2 -2
  8. package/dist/{client-DXJRow2s.d.cts → client-Dk4H7qeg.d.cts} +2 -2
  9. package/dist/codec/index.cjs.map +1 -1
  10. package/dist/codec/index.d.cts +3 -3
  11. package/dist/codec/index.d.ts +3 -3
  12. package/dist/codec/index.js +2 -2
  13. package/dist/{connection-Dzkqj18h.d.cts → connection-CS00EWuS.d.cts} +3 -3
  14. package/dist/{connection-C2lYgRh0.d.ts → connection-DU9v3y8a.d.ts} +3 -3
  15. package/dist/{index-D9R6UTMl.d.cts → index-CHCzvZ9D.d.cts} +1 -1
  16. package/dist/{index-CSM8soK7.d.ts → index-uF0cBM7z.d.ts} +1 -1
  17. package/dist/logging/index.d.cts +2 -2
  18. package/dist/logging/index.d.ts +2 -2
  19. package/dist/{message-Dlsh5WDF.d.cts → message-aABg0s5M.d.cts} +12 -1
  20. package/dist/{message-Dlsh5WDF.d.ts → message-aABg0s5M.d.ts} +12 -1
  21. package/dist/router/index.cjs +14 -9
  22. package/dist/router/index.cjs.map +1 -1
  23. package/dist/router/index.d.cts +10 -10
  24. package/dist/router/index.d.ts +10 -10
  25. package/dist/router/index.js +1 -1
  26. package/dist/{server-BDSYa-CO.d.cts → server-BR0DZaWi.d.cts} +4 -4
  27. package/dist/{server-DFOzjvLh.d.ts → server-uNzkzIRh.d.ts} +4 -4
  28. package/dist/{services-D47_GPCH.d.ts → services-B5SY771g.d.ts} +3 -3
  29. package/dist/{services-DqYQvm_L.d.cts → services-DBv2nmly.d.cts} +3 -3
  30. package/dist/testUtil/index.cjs +179 -53
  31. package/dist/testUtil/index.cjs.map +1 -1
  32. package/dist/testUtil/index.d.cts +7 -7
  33. package/dist/testUtil/index.d.ts +7 -7
  34. package/dist/testUtil/index.js +4 -2
  35. package/dist/testUtil/index.js.map +1 -1
  36. package/dist/transport/impls/ws/client.cjs +166 -53
  37. package/dist/transport/impls/ws/client.cjs.map +1 -1
  38. package/dist/transport/impls/ws/client.d.cts +6 -6
  39. package/dist/transport/impls/ws/client.d.ts +6 -6
  40. package/dist/transport/impls/ws/client.js +2 -2
  41. package/dist/transport/impls/ws/server.cjs +133 -53
  42. package/dist/transport/impls/ws/server.cjs.map +1 -1
  43. package/dist/transport/impls/ws/server.d.cts +6 -6
  44. package/dist/transport/impls/ws/server.d.ts +6 -6
  45. package/dist/transport/impls/ws/server.js +2 -2
  46. package/dist/transport/index.cjs +177 -53
  47. package/dist/transport/index.cjs.map +1 -1
  48. package/dist/transport/index.d.cts +7 -7
  49. package/dist/transport/index.d.ts +7 -7
  50. package/dist/transport/index.js +2 -2
  51. package/dist/{transport-CxT7y8Qk.d.cts → transport-BOL2p5s-.d.ts} +70 -64
  52. package/dist/{transport-pdbkDzmJ.d.ts → transport-D3jzhFSi.d.cts} +70 -64
  53. package/package.json +1 -1
  54. package/dist/chunk-DRYCLL6N.js.map +0 -1
  55. package/dist/chunk-LECVFB2G.js.map +0 -1
@@ -1,12 +1,12 @@
1
- import { C as ClientTransport } from '../../../client-DXJRow2s.cjs';
2
- import { c as TransportClientId } from '../../../message-Dlsh5WDF.cjs';
3
- import { b as ProvidedClientTransportOptions } from '../../../transport-CxT7y8Qk.cjs';
4
- import { a as WebSocketConnection } from '../../../connection-Dzkqj18h.cjs';
1
+ import { C as ClientTransport } from '../../../client-Dk4H7qeg.cjs';
2
+ import { c as TransportClientId } from '../../../message-aABg0s5M.cjs';
3
+ import { b as ProvidedClientTransportOptions } from '../../../transport-D3jzhFSi.cjs';
4
+ import { a as WebSocketConnection } from '../../../connection-CS00EWuS.cjs';
5
5
  import { W as WsLike } from '../../../wslike-Dng9H1C7.cjs';
6
6
  import '@sinclair/typebox';
7
7
  import '@opentelemetry/api';
8
- import '../../../index-D9R6UTMl.cjs';
9
- import '../../../adapter-DjiEwOYi.cjs';
8
+ import '../../../index-CHCzvZ9D.cjs';
9
+ import '../../../adapter-IGrG4KLL.cjs';
10
10
 
11
11
  /**
12
12
  * A transport implementation that uses a WebSocket connection with automatic reconnection.
@@ -1,12 +1,12 @@
1
- import { C as ClientTransport } from '../../../client-Dw0JBBs3.js';
2
- import { c as TransportClientId } from '../../../message-Dlsh5WDF.js';
3
- import { b as ProvidedClientTransportOptions } from '../../../transport-pdbkDzmJ.js';
4
- import { a as WebSocketConnection } from '../../../connection-C2lYgRh0.js';
1
+ import { C as ClientTransport } from '../../../client-BhwlY0-L.js';
2
+ import { c as TransportClientId } from '../../../message-aABg0s5M.js';
3
+ import { b as ProvidedClientTransportOptions } from '../../../transport-BOL2p5s-.js';
4
+ import { a as WebSocketConnection } from '../../../connection-DU9v3y8a.js';
5
5
  import { W as WsLike } from '../../../wslike-Dng9H1C7.js';
6
6
  import '@sinclair/typebox';
7
7
  import '@opentelemetry/api';
8
- import '../../../index-CSM8soK7.js';
9
- import '../../../adapter-Cp7_gIVA.js';
8
+ import '../../../index-uF0cBM7z.js';
9
+ import '../../../adapter-CgF7vQPu.js';
10
10
 
11
11
  /**
12
12
  * A transport implementation that uses a WebSocket connection with automatic reconnection.
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  ClientTransport,
3
3
  WebSocketConnection
4
- } from "../../../chunk-DRYCLL6N.js";
4
+ } from "../../../chunk-VXRAFUA3.js";
5
5
  import "../../../chunk-CC7RN7GI.js";
6
- import "../../../chunk-LECVFB2G.js";
6
+ import "../../../chunk-RDTQZ7HO.js";
7
7
 
8
8
  // transport/impls/ws/client.ts
9
9
  var WebSocketClientTransport = class extends ClientTransport {
@@ -532,6 +532,7 @@ var IdentifiedSession = class extends CommonSession {
532
532
  telemetry;
533
533
  to;
534
534
  protocolVersion;
535
+ listeners;
535
536
  /**
536
537
  * Index of the message we will send next (excluding handshake)
537
538
  */
@@ -555,7 +556,8 @@ var IdentifiedSession = class extends CommonSession {
555
556
  telemetry,
556
557
  log,
557
558
  protocolVersion,
558
- seqSent: messagesSent
559
+ seqSent: messagesSent,
560
+ listeners
559
561
  } = props;
560
562
  super(props);
561
563
  this.id = id;
@@ -567,6 +569,7 @@ var IdentifiedSession = class extends CommonSession {
567
569
  this.log = log;
568
570
  this.protocolVersion = protocolVersion;
569
571
  this.seqSent = messagesSent;
572
+ this.listeners = listeners;
570
573
  }
571
574
  get loggingMetadata() {
572
575
  const metadata = {
@@ -583,7 +586,7 @@ var IdentifiedSession = class extends CommonSession {
583
586
  }
584
587
  return metadata;
585
588
  }
586
- constructMsg(partialMsg) {
589
+ encodeMsg(partialMsg) {
587
590
  const msg = {
588
591
  ...partialMsg,
589
592
  id: generateId(),
@@ -592,18 +595,37 @@ var IdentifiedSession = class extends CommonSession {
592
595
  seq: this.seq,
593
596
  ack: this.ack
594
597
  };
598
+ const encoded = this.codec.toBuffer(msg);
599
+ if (!encoded.ok) {
600
+ this.listeners.onMessageSendFailure(
601
+ { ...partialMsg, seq: this.seq },
602
+ encoded.reason
603
+ );
604
+ return encoded;
605
+ }
595
606
  this.seq++;
596
- return msg;
607
+ return {
608
+ ok: true,
609
+ value: {
610
+ id: msg.id,
611
+ seq: msg.seq,
612
+ msg: partialMsg,
613
+ data: encoded.value
614
+ }
615
+ };
597
616
  }
598
617
  nextSeq() {
599
618
  return this.sendBuffer.length > 0 ? this.sendBuffer[0].seq : this.seq;
600
619
  }
601
620
  send(msg) {
602
- const constructedMsg = this.constructMsg(msg);
603
- this.sendBuffer.push(constructedMsg);
621
+ const encodeResult = this.encodeMsg(msg);
622
+ if (!encodeResult.ok) {
623
+ return encodeResult;
624
+ }
625
+ this.sendBuffer.push(encodeResult.value);
604
626
  return {
605
627
  ok: true,
606
- value: constructedMsg.id
628
+ value: encodeResult.value.id
607
629
  };
608
630
  }
609
631
  _handleStateExit() {
@@ -636,23 +658,6 @@ var IdentifiedSessionWithGracePeriod = class extends IdentifiedSession {
636
658
  super._handleClose();
637
659
  }
638
660
  };
639
- function sendMessage(conn, codec, msg) {
640
- const buff = codec.toBuffer(msg);
641
- if (!buff.ok) {
642
- return buff;
643
- }
644
- const sent = conn.send(buff.value);
645
- if (!sent) {
646
- return {
647
- ok: false,
648
- reason: "failed to send message"
649
- };
650
- }
651
- return {
652
- ok: true,
653
- value: msg.id
654
- };
655
- }
656
661
 
657
662
  // transport/sessionStateMachine/SessionConnecting.ts
658
663
  var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
@@ -731,7 +736,7 @@ function coerceErrorString(err) {
731
736
  }
732
737
 
733
738
  // package.json
734
- var version = "0.214.0";
739
+ var version = "0.215.0";
735
740
 
736
741
  // tracing/index.ts
737
742
  function createSessionTelemetryInfo(tracer, sessionId, to, from, propagationCtx) {
@@ -806,7 +811,21 @@ var SessionWaitingForHandshake = class extends CommonSession {
806
811
  this.listeners.onHandshake(parsedMsgRes.value);
807
812
  };
808
813
  sendHandshake(msg) {
809
- return sendMessage(this.conn, this.codec, msg);
814
+ const buff = this.codec.toBuffer(msg);
815
+ if (!buff.ok) {
816
+ return buff;
817
+ }
818
+ const sent = this.conn.send(buff.value);
819
+ if (!sent) {
820
+ return {
821
+ ok: false,
822
+ reason: "failed to send handshake"
823
+ };
824
+ }
825
+ return {
826
+ ok: true,
827
+ value: msg.id
828
+ };
810
829
  }
811
830
  _handleStateExit() {
812
831
  this.conn.removeDataListener();
@@ -855,7 +874,21 @@ var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
855
874
  this.listeners.onHandshake(parsedMsgRes.value);
856
875
  };
857
876
  sendHandshake(msg) {
858
- return sendMessage(this.conn, this.codec, msg);
877
+ const buff = this.codec.toBuffer(msg);
878
+ if (!buff.ok) {
879
+ return buff;
880
+ }
881
+ const sent = this.conn.send(buff.value);
882
+ if (!sent) {
883
+ return {
884
+ ok: false,
885
+ reason: "failed to send handshake"
886
+ };
887
+ }
888
+ return {
889
+ ok: true,
890
+ value: msg.id
891
+ };
859
892
  }
860
893
  _handleStateExit() {
861
894
  super._handleStateExit();
@@ -890,28 +923,35 @@ var SessionConnected = class extends IdentifiedSession {
890
923
  }
891
924
  this.startMissingHeartbeatTimeout();
892
925
  }
893
- assertSendOrdering(constructedMsg) {
894
- if (constructedMsg.seq > this.seqSent + 1) {
895
- const msg = `invariant violation: would have sent out of order msg (seq: ${constructedMsg.seq}, expected: ${this.seqSent} + 1)`;
926
+ assertSendOrdering(encodedMsg) {
927
+ if (encodedMsg.seq > this.seqSent + 1) {
928
+ const msg = `invariant violation: would have sent out of order msg (seq: ${encodedMsg.seq}, expected: ${this.seqSent} + 1)`;
896
929
  this.log?.error(msg, {
897
930
  ...this.loggingMetadata,
898
- transportMessage: constructedMsg,
899
931
  tags: ["invariant-violation"]
900
932
  });
901
933
  throw new Error(msg);
902
934
  }
903
935
  }
904
936
  send(msg) {
905
- const constructedMsg = this.constructMsg(msg);
906
- this.assertSendOrdering(constructedMsg);
907
- this.sendBuffer.push(constructedMsg);
908
- const res = sendMessage(this.conn, this.codec, constructedMsg);
909
- if (!res.ok) {
910
- this.listeners.onMessageSendFailure(constructedMsg, res.reason);
911
- return res;
937
+ const encodeResult = this.encodeMsg(msg);
938
+ if (!encodeResult.ok) {
939
+ return encodeResult;
940
+ }
941
+ const encodedMsg = encodeResult.value;
942
+ this.assertSendOrdering(encodedMsg);
943
+ this.sendBuffer.push(encodedMsg);
944
+ const sent = this.conn.send(encodedMsg.data);
945
+ if (!sent) {
946
+ const reason = "failed to send message";
947
+ this.listeners.onMessageSendFailure(
948
+ { ...encodedMsg.msg, seq: encodedMsg.seq },
949
+ reason
950
+ );
951
+ return { ok: false, reason };
912
952
  }
913
- this.seqSent = constructedMsg.seq;
914
- return res;
953
+ this.seqSent = encodedMsg.seq;
954
+ return { ok: true, value: encodedMsg.id };
915
955
  }
916
956
  constructor(props) {
917
957
  super(props);
@@ -929,10 +969,14 @@ var SessionConnected = class extends IdentifiedSession {
929
969
  );
930
970
  for (const msg of this.sendBuffer) {
931
971
  this.assertSendOrdering(msg);
932
- const res = sendMessage(this.conn, this.codec, msg);
933
- if (!res.ok) {
934
- this.listeners.onMessageSendFailure(msg, res.reason);
935
- return res;
972
+ const sent = this.conn.send(msg.data);
973
+ if (!sent) {
974
+ const reason = "failed to send buffered message";
975
+ this.listeners.onMessageSendFailure(
976
+ { ...msg.msg, seq: msg.seq },
977
+ reason
978
+ );
979
+ return { ok: false, reason };
936
980
  }
937
981
  this.seqSent = msg.seq;
938
982
  }
@@ -1593,6 +1637,17 @@ var Transport = class {
1593
1637
  const noConnectionSession = SessionStateGraph.transition.ConnectingToNoConnection(session, {
1594
1638
  onSessionGracePeriodElapsed: () => {
1595
1639
  this.onSessionGracePeriodElapsed(noConnectionSession);
1640
+ },
1641
+ onMessageSendFailure: (msg, reason) => {
1642
+ this.log?.error(`failed to send message: ${reason}`, {
1643
+ ...noConnectionSession.loggingMetadata,
1644
+ transportMessage: msg
1645
+ });
1646
+ this.protocolError({
1647
+ type: ProtocolError.MessageSendFailure,
1648
+ message: reason
1649
+ });
1650
+ this.deleteSession(noConnectionSession, { unhealthy: true });
1596
1651
  }
1597
1652
  });
1598
1653
  this.updateSession(noConnectionSession);
@@ -1600,18 +1655,32 @@ var Transport = class {
1600
1655
  }
1601
1656
  onConnClosed(session) {
1602
1657
  let noConnectionSession;
1658
+ const listeners = {
1659
+ onSessionGracePeriodElapsed: () => {
1660
+ this.onSessionGracePeriodElapsed(noConnectionSession);
1661
+ },
1662
+ onMessageSendFailure: (msg, reason) => {
1663
+ this.log?.error(`failed to send message: ${reason}`, {
1664
+ ...noConnectionSession.loggingMetadata,
1665
+ transportMessage: msg
1666
+ });
1667
+ this.protocolError({
1668
+ type: ProtocolError.MessageSendFailure,
1669
+ message: reason
1670
+ });
1671
+ this.deleteSession(noConnectionSession, { unhealthy: true });
1672
+ }
1673
+ };
1603
1674
  if (session.state === "Handshaking" /* Handshaking */) {
1604
- noConnectionSession = SessionStateGraph.transition.HandshakingToNoConnection(session, {
1605
- onSessionGracePeriodElapsed: () => {
1606
- this.onSessionGracePeriodElapsed(noConnectionSession);
1607
- }
1608
- });
1675
+ noConnectionSession = SessionStateGraph.transition.HandshakingToNoConnection(
1676
+ session,
1677
+ listeners
1678
+ );
1609
1679
  } else {
1610
- noConnectionSession = SessionStateGraph.transition.ConnectedToNoConnection(session, {
1611
- onSessionGracePeriodElapsed: () => {
1612
- this.onSessionGracePeriodElapsed(noConnectionSession);
1613
- }
1614
- });
1680
+ noConnectionSession = SessionStateGraph.transition.ConnectedToNoConnection(
1681
+ session,
1682
+ listeners
1683
+ );
1615
1684
  }
1616
1685
  this.updateSession(noConnectionSession);
1617
1686
  return noConnectionSession;
@@ -1918,6 +1987,17 @@ var ServerTransport = class extends Transport {
1918
1987
  {
1919
1988
  onSessionGracePeriodElapsed: () => {
1920
1989
  this.onSessionGracePeriodElapsed(noConnectionSession);
1990
+ },
1991
+ onMessageSendFailure: (msg2, reason) => {
1992
+ this.log?.error(`failed to send message: ${reason}`, {
1993
+ ...noConnectionSession.loggingMetadata,
1994
+ transportMessage: msg2
1995
+ });
1996
+ this.protocolError({
1997
+ type: ProtocolError.MessageSendFailure,
1998
+ message: reason
1999
+ });
2000
+ this.deleteSession(noConnectionSession, { unhealthy: true });
1921
2001
  }
1922
2002
  }
1923
2003
  );