@replit/river 0.214.0 → 0.215.1

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-DjiEwOYi.d.cts → adapter-CjgmjtUJ.d.cts} +3 -2
  2. package/dist/{adapter-Cp7_gIVA.d.ts → adapter-Dtt4bYL-.d.ts} +3 -2
  3. package/dist/{chunk-DRYCLL6N.js → chunk-3DDZCLJM.js} +182 -54
  4. package/dist/chunk-3DDZCLJM.js.map +1 -0
  5. package/dist/{chunk-LECVFB2G.js → chunk-NUGV5QWU.js} +15 -10
  6. package/dist/chunk-NUGV5QWU.js.map +1 -0
  7. package/dist/{client-DXJRow2s.d.cts → client-B9aKi9Li.d.cts} +2 -2
  8. package/dist/{client-Dw0JBBs3.d.ts → client-BOc8blGj.d.ts} +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-1hFoyxuX.d.cts} +3 -3
  14. package/dist/{connection-C2lYgRh0.d.ts → connection-DnMYvolf.d.ts} +3 -3
  15. package/dist/{index-D9R6UTMl.d.cts → index-Bf9PGbS4.d.cts} +1 -1
  16. package/dist/{index-CSM8soK7.d.ts → index-DiAq34gk.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-DL74OqsX.d.cts} +12 -1
  20. package/dist/{message-Dlsh5WDF.d.ts → message-DL74OqsX.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 +11 -11
  24. package/dist/router/index.d.ts +11 -11
  25. package/dist/router/index.js +1 -1
  26. package/dist/{server-BDSYa-CO.d.cts → server-BkEzDYIv.d.cts} +4 -4
  27. package/dist/{server-DFOzjvLh.d.ts → server-_bfE7LYc.d.ts} +4 -4
  28. package/dist/{services-D47_GPCH.d.ts → services-KdKBWdJr.d.ts} +4 -4
  29. package/dist/{services-DqYQvm_L.d.cts → services-zaansuuR.d.cts} +4 -4
  30. package/dist/testUtil/index.cjs +183 -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 +170 -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 +181 -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-pdbkDzmJ.d.ts → transport-CCBNESLA.d.cts} +72 -65
  52. package/dist/{transport-CxT7y8Qk.d.cts → transport-kW92H6x-.d.ts} +72 -65
  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,14 +1,14 @@
1
- import { c as TransportClientId } from '../../../message-Dlsh5WDF.cjs';
1
+ import { T as TransportClientId } from '../../../message-DL74OqsX.cjs';
2
2
  import { WebSocketServer } from 'ws';
3
- import { a as WebSocketConnection } from '../../../connection-Dzkqj18h.cjs';
3
+ import { a as WebSocketConnection } from '../../../connection-1hFoyxuX.cjs';
4
4
  import { W as WsLike } from '../../../wslike-Dng9H1C7.cjs';
5
- import { S as ServerTransport } from '../../../server-BDSYa-CO.cjs';
6
- import { c as ProvidedServerTransportOptions } from '../../../transport-CxT7y8Qk.cjs';
5
+ import { S as ServerTransport } from '../../../server-BkEzDYIv.cjs';
6
+ import { e as ProvidedServerTransportOptions } from '../../../transport-CCBNESLA.cjs';
7
7
  import { IncomingMessage } from 'http';
8
8
  import { TSchema } from '@sinclair/typebox';
9
9
  import '@opentelemetry/api';
10
- import '../../../index-D9R6UTMl.cjs';
11
- import '../../../adapter-DjiEwOYi.cjs';
10
+ import '../../../index-Bf9PGbS4.cjs';
11
+ import '../../../adapter-CjgmjtUJ.cjs';
12
12
 
13
13
  declare class WebSocketServerTransport<MetadataSchema extends TSchema = TSchema, ParsedMetadata extends object = object> extends ServerTransport<WebSocketConnection, MetadataSchema, ParsedMetadata> {
14
14
  wss: WebSocketServer;
@@ -1,14 +1,14 @@
1
- import { c as TransportClientId } from '../../../message-Dlsh5WDF.js';
1
+ import { T as TransportClientId } from '../../../message-DL74OqsX.js';
2
2
  import { WebSocketServer } from 'ws';
3
- import { a as WebSocketConnection } from '../../../connection-C2lYgRh0.js';
3
+ import { a as WebSocketConnection } from '../../../connection-DnMYvolf.js';
4
4
  import { W as WsLike } from '../../../wslike-Dng9H1C7.js';
5
- import { S as ServerTransport } from '../../../server-DFOzjvLh.js';
6
- import { c as ProvidedServerTransportOptions } from '../../../transport-pdbkDzmJ.js';
5
+ import { S as ServerTransport } from '../../../server-_bfE7LYc.js';
6
+ import { e as ProvidedServerTransportOptions } from '../../../transport-kW92H6x-.js';
7
7
  import { IncomingMessage } from 'http';
8
8
  import { TSchema } from '@sinclair/typebox';
9
9
  import '@opentelemetry/api';
10
- import '../../../index-CSM8soK7.js';
11
- import '../../../adapter-Cp7_gIVA.js';
10
+ import '../../../index-DiAq34gk.js';
11
+ import '../../../adapter-Dtt4bYL-.js';
12
12
 
13
13
  declare class WebSocketServerTransport<MetadataSchema extends TSchema = TSchema, ParsedMetadata extends object = object> extends ServerTransport<WebSocketConnection, MetadataSchema, ParsedMetadata> {
14
14
  wss: WebSocketServer;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  ServerTransport,
3
3
  WebSocketConnection
4
- } from "../../../chunk-DRYCLL6N.js";
4
+ } from "../../../chunk-3DDZCLJM.js";
5
5
  import "../../../chunk-CC7RN7GI.js";
6
- import "../../../chunk-LECVFB2G.js";
6
+ import "../../../chunk-NUGV5QWU.js";
7
7
 
8
8
  // transport/impls/ws/server.ts
9
9
  function cleanHeaders(headers) {
@@ -307,6 +307,7 @@ var IdentifiedSession = class extends CommonSession {
307
307
  telemetry;
308
308
  to;
309
309
  protocolVersion;
310
+ listeners;
310
311
  /**
311
312
  * Index of the message we will send next (excluding handshake)
312
313
  */
@@ -330,7 +331,8 @@ var IdentifiedSession = class extends CommonSession {
330
331
  telemetry,
331
332
  log,
332
333
  protocolVersion,
333
- seqSent: messagesSent
334
+ seqSent: messagesSent,
335
+ listeners
334
336
  } = props;
335
337
  super(props);
336
338
  this.id = id;
@@ -342,6 +344,7 @@ var IdentifiedSession = class extends CommonSession {
342
344
  this.log = log;
343
345
  this.protocolVersion = protocolVersion;
344
346
  this.seqSent = messagesSent;
347
+ this.listeners = listeners;
345
348
  }
346
349
  get loggingMetadata() {
347
350
  const metadata = {
@@ -358,7 +361,7 @@ var IdentifiedSession = class extends CommonSession {
358
361
  }
359
362
  return metadata;
360
363
  }
361
- constructMsg(partialMsg) {
364
+ encodeMsg(partialMsg) {
362
365
  const msg = {
363
366
  ...partialMsg,
364
367
  id: generateId(),
@@ -367,18 +370,37 @@ var IdentifiedSession = class extends CommonSession {
367
370
  seq: this.seq,
368
371
  ack: this.ack
369
372
  };
373
+ const encoded = this.codec.toBuffer(msg);
374
+ if (!encoded.ok) {
375
+ this.listeners.onMessageSendFailure(
376
+ { ...partialMsg, seq: this.seq },
377
+ encoded.reason
378
+ );
379
+ return encoded;
380
+ }
370
381
  this.seq++;
371
- return msg;
382
+ return {
383
+ ok: true,
384
+ value: {
385
+ id: msg.id,
386
+ seq: msg.seq,
387
+ msg: partialMsg,
388
+ data: encoded.value
389
+ }
390
+ };
372
391
  }
373
392
  nextSeq() {
374
393
  return this.sendBuffer.length > 0 ? this.sendBuffer[0].seq : this.seq;
375
394
  }
376
395
  send(msg) {
377
- const constructedMsg = this.constructMsg(msg);
378
- this.sendBuffer.push(constructedMsg);
396
+ const encodeResult = this.encodeMsg(msg);
397
+ if (!encodeResult.ok) {
398
+ return encodeResult;
399
+ }
400
+ this.sendBuffer.push(encodeResult.value);
379
401
  return {
380
402
  ok: true,
381
- value: constructedMsg.id
403
+ value: encodeResult.value.id
382
404
  };
383
405
  }
384
406
  _handleStateExit() {
@@ -411,23 +433,6 @@ var IdentifiedSessionWithGracePeriod = class extends IdentifiedSession {
411
433
  super._handleClose();
412
434
  }
413
435
  };
414
- function sendMessage(conn, codec, msg) {
415
- const buff = codec.toBuffer(msg);
416
- if (!buff.ok) {
417
- return buff;
418
- }
419
- const sent = conn.send(buff.value);
420
- if (!sent) {
421
- return {
422
- ok: false,
423
- reason: "failed to send message"
424
- };
425
- }
426
- return {
427
- ok: true,
428
- value: msg.id
429
- };
430
- }
431
436
 
432
437
  // transport/sessionStateMachine/SessionConnecting.ts
433
438
  var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
@@ -647,7 +652,7 @@ function coerceErrorString(err) {
647
652
  }
648
653
 
649
654
  // package.json
650
- var version = "0.214.0";
655
+ var version = "0.215.1";
651
656
 
652
657
  // tracing/index.ts
653
658
  function getPropagationContext(ctx) {
@@ -730,7 +735,21 @@ var SessionWaitingForHandshake = class extends CommonSession {
730
735
  this.listeners.onHandshake(parsedMsgRes.value);
731
736
  };
732
737
  sendHandshake(msg) {
733
- return sendMessage(this.conn, this.codec, msg);
738
+ const buff = this.codec.toBuffer(msg);
739
+ if (!buff.ok) {
740
+ return buff;
741
+ }
742
+ const sent = this.conn.send(buff.value);
743
+ if (!sent) {
744
+ return {
745
+ ok: false,
746
+ reason: "failed to send handshake"
747
+ };
748
+ }
749
+ return {
750
+ ok: true,
751
+ value: msg.id
752
+ };
734
753
  }
735
754
  _handleStateExit() {
736
755
  this.conn.removeDataListener();
@@ -779,7 +798,21 @@ var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
779
798
  this.listeners.onHandshake(parsedMsgRes.value);
780
799
  };
781
800
  sendHandshake(msg) {
782
- return sendMessage(this.conn, this.codec, msg);
801
+ const buff = this.codec.toBuffer(msg);
802
+ if (!buff.ok) {
803
+ return buff;
804
+ }
805
+ const sent = this.conn.send(buff.value);
806
+ if (!sent) {
807
+ return {
808
+ ok: false,
809
+ reason: "failed to send handshake"
810
+ };
811
+ }
812
+ return {
813
+ ok: true,
814
+ value: msg.id
815
+ };
783
816
  }
784
817
  _handleStateExit() {
785
818
  super._handleStateExit();
@@ -814,28 +847,35 @@ var SessionConnected = class extends IdentifiedSession {
814
847
  }
815
848
  this.startMissingHeartbeatTimeout();
816
849
  }
817
- assertSendOrdering(constructedMsg) {
818
- if (constructedMsg.seq > this.seqSent + 1) {
819
- const msg = `invariant violation: would have sent out of order msg (seq: ${constructedMsg.seq}, expected: ${this.seqSent} + 1)`;
850
+ assertSendOrdering(encodedMsg) {
851
+ if (encodedMsg.seq > this.seqSent + 1) {
852
+ const msg = `invariant violation: would have sent out of order msg (seq: ${encodedMsg.seq}, expected: ${this.seqSent} + 1)`;
820
853
  this.log?.error(msg, {
821
854
  ...this.loggingMetadata,
822
- transportMessage: constructedMsg,
823
855
  tags: ["invariant-violation"]
824
856
  });
825
857
  throw new Error(msg);
826
858
  }
827
859
  }
828
860
  send(msg) {
829
- const constructedMsg = this.constructMsg(msg);
830
- this.assertSendOrdering(constructedMsg);
831
- this.sendBuffer.push(constructedMsg);
832
- const res = sendMessage(this.conn, this.codec, constructedMsg);
833
- if (!res.ok) {
834
- this.listeners.onMessageSendFailure(constructedMsg, res.reason);
835
- return res;
861
+ const encodeResult = this.encodeMsg(msg);
862
+ if (!encodeResult.ok) {
863
+ return encodeResult;
864
+ }
865
+ const encodedMsg = encodeResult.value;
866
+ this.assertSendOrdering(encodedMsg);
867
+ this.sendBuffer.push(encodedMsg);
868
+ const sent = this.conn.send(encodedMsg.data);
869
+ if (!sent) {
870
+ const reason = "failed to send message";
871
+ this.listeners.onMessageSendFailure(
872
+ { ...encodedMsg.msg, seq: encodedMsg.seq },
873
+ reason
874
+ );
875
+ return { ok: false, reason };
836
876
  }
837
- this.seqSent = constructedMsg.seq;
838
- return res;
877
+ this.seqSent = encodedMsg.seq;
878
+ return { ok: true, value: encodedMsg.id };
839
879
  }
840
880
  constructor(props) {
841
881
  super(props);
@@ -853,10 +893,14 @@ var SessionConnected = class extends IdentifiedSession {
853
893
  );
854
894
  for (const msg of this.sendBuffer) {
855
895
  this.assertSendOrdering(msg);
856
- const res = sendMessage(this.conn, this.codec, msg);
857
- if (!res.ok) {
858
- this.listeners.onMessageSendFailure(msg, res.reason);
859
- return res;
896
+ const sent = this.conn.send(msg.data);
897
+ if (!sent) {
898
+ const reason = "failed to send buffered message";
899
+ this.listeners.onMessageSendFailure(
900
+ { ...msg.msg, seq: msg.seq },
901
+ reason
902
+ );
903
+ return { ok: false, reason };
860
904
  }
861
905
  this.seqSent = msg.seq;
862
906
  }
@@ -1517,6 +1561,17 @@ var Transport = class {
1517
1561
  const noConnectionSession = SessionStateGraph.transition.ConnectingToNoConnection(session, {
1518
1562
  onSessionGracePeriodElapsed: () => {
1519
1563
  this.onSessionGracePeriodElapsed(noConnectionSession);
1564
+ },
1565
+ onMessageSendFailure: (msg, reason) => {
1566
+ this.log?.error(`failed to send message: ${reason}`, {
1567
+ ...noConnectionSession.loggingMetadata,
1568
+ transportMessage: msg
1569
+ });
1570
+ this.protocolError({
1571
+ type: ProtocolError.MessageSendFailure,
1572
+ message: reason
1573
+ });
1574
+ this.deleteSession(noConnectionSession, { unhealthy: true });
1520
1575
  }
1521
1576
  });
1522
1577
  this.updateSession(noConnectionSession);
@@ -1524,18 +1579,32 @@ var Transport = class {
1524
1579
  }
1525
1580
  onConnClosed(session) {
1526
1581
  let noConnectionSession;
1582
+ const listeners = {
1583
+ onSessionGracePeriodElapsed: () => {
1584
+ this.onSessionGracePeriodElapsed(noConnectionSession);
1585
+ },
1586
+ onMessageSendFailure: (msg, reason) => {
1587
+ this.log?.error(`failed to send message: ${reason}`, {
1588
+ ...noConnectionSession.loggingMetadata,
1589
+ transportMessage: msg
1590
+ });
1591
+ this.protocolError({
1592
+ type: ProtocolError.MessageSendFailure,
1593
+ message: reason
1594
+ });
1595
+ this.deleteSession(noConnectionSession, { unhealthy: true });
1596
+ }
1597
+ };
1527
1598
  if (session.state === "Handshaking" /* Handshaking */) {
1528
- noConnectionSession = SessionStateGraph.transition.HandshakingToNoConnection(session, {
1529
- onSessionGracePeriodElapsed: () => {
1530
- this.onSessionGracePeriodElapsed(noConnectionSession);
1531
- }
1532
- });
1599
+ noConnectionSession = SessionStateGraph.transition.HandshakingToNoConnection(
1600
+ session,
1601
+ listeners
1602
+ );
1533
1603
  } else {
1534
- noConnectionSession = SessionStateGraph.transition.ConnectedToNoConnection(session, {
1535
- onSessionGracePeriodElapsed: () => {
1536
- this.onSessionGracePeriodElapsed(noConnectionSession);
1537
- }
1538
- });
1604
+ noConnectionSession = SessionStateGraph.transition.ConnectedToNoConnection(
1605
+ session,
1606
+ listeners
1607
+ );
1539
1608
  }
1540
1609
  this.updateSession(noConnectionSession);
1541
1610
  return noConnectionSession;
@@ -1639,6 +1708,10 @@ var LeakyBucketRateLimit = class {
1639
1708
  clearInterval(this.intervalHandle);
1640
1709
  this.intervalHandle = void 0;
1641
1710
  }
1711
+ resetBudget() {
1712
+ this.stopLeak();
1713
+ this.budgetConsumed = 0;
1714
+ }
1642
1715
  close() {
1643
1716
  this.stopLeak();
1644
1717
  }
@@ -1696,6 +1769,17 @@ var ClientTransport = class extends Transport {
1696
1769
  {
1697
1770
  onSessionGracePeriodElapsed: () => {
1698
1771
  this.onSessionGracePeriodElapsed(session);
1772
+ },
1773
+ onMessageSendFailure: (msg, reason) => {
1774
+ this.log?.error(`failed to send message: ${reason}`, {
1775
+ ...session.loggingMetadata,
1776
+ transportMessage: msg
1777
+ });
1778
+ this.protocolError({
1779
+ type: ProtocolError.MessageSendFailure,
1780
+ message: reason
1781
+ });
1782
+ this.deleteSession(session, { unhealthy: true });
1699
1783
  }
1700
1784
  },
1701
1785
  this.options,
@@ -1760,6 +1844,17 @@ var ClientTransport = class extends Transport {
1760
1844
  },
1761
1845
  onSessionGracePeriodElapsed: () => {
1762
1846
  this.onSessionGracePeriodElapsed(handshakingSession);
1847
+ },
1848
+ onMessageSendFailure: (msg, reason) => {
1849
+ this.log?.error(`failed to send message: ${reason}`, {
1850
+ ...handshakingSession.loggingMetadata,
1851
+ transportMessage: msg
1852
+ });
1853
+ this.protocolError({
1854
+ type: ProtocolError.MessageSendFailure,
1855
+ message: reason
1856
+ });
1857
+ this.deleteSession(handshakingSession, { unhealthy: true });
1763
1858
  }
1764
1859
  }
1765
1860
  );
@@ -1921,6 +2016,17 @@ var ClientTransport = class extends Transport {
1921
2016
  },
1922
2017
  onSessionGracePeriodElapsed: () => {
1923
2018
  this.onSessionGracePeriodElapsed(backingOffSession);
2019
+ },
2020
+ onMessageSendFailure: (msg, reason) => {
2021
+ this.log?.error(`failed to send message: ${reason}`, {
2022
+ ...backingOffSession.loggingMetadata,
2023
+ transportMessage: msg
2024
+ });
2025
+ this.protocolError({
2026
+ type: ProtocolError.MessageSendFailure,
2027
+ message: reason
2028
+ });
2029
+ this.deleteSession(backingOffSession, { unhealthy: true });
1924
2030
  }
1925
2031
  }
1926
2032
  );
@@ -1984,6 +2090,17 @@ var ClientTransport = class extends Transport {
1984
2090
  },
1985
2091
  onSessionGracePeriodElapsed: () => {
1986
2092
  this.onSessionGracePeriodElapsed(connectingSession);
2093
+ },
2094
+ onMessageSendFailure: (msg, reason) => {
2095
+ this.log?.error(`failed to send message: ${reason}`, {
2096
+ ...connectingSession.loggingMetadata,
2097
+ transportMessage: msg
2098
+ });
2099
+ this.protocolError({
2100
+ type: ProtocolError.MessageSendFailure,
2101
+ message: reason
2102
+ });
2103
+ this.deleteSession(connectingSession, { unhealthy: true });
1987
2104
  }
1988
2105
  }
1989
2106
  );
@@ -2314,6 +2431,17 @@ var ServerTransport = class extends Transport {
2314
2431
  {
2315
2432
  onSessionGracePeriodElapsed: () => {
2316
2433
  this.onSessionGracePeriodElapsed(noConnectionSession);
2434
+ },
2435
+ onMessageSendFailure: (msg2, reason) => {
2436
+ this.log?.error(`failed to send message: ${reason}`, {
2437
+ ...noConnectionSession.loggingMetadata,
2438
+ transportMessage: msg2
2439
+ });
2440
+ this.protocolError({
2441
+ type: ProtocolError.MessageSendFailure,
2442
+ message: reason
2443
+ });
2444
+ this.deleteSession(noConnectionSession, { unhealthy: true });
2317
2445
  }
2318
2446
  }
2319
2447
  );