@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,14 +1,14 @@
1
- import { c as TransportClientId } from '../../../message-Dlsh5WDF.cjs';
1
+ import { c as TransportClientId } from '../../../message-aABg0s5M.cjs';
2
2
  import { WebSocketServer } from 'ws';
3
- import { a as WebSocketConnection } from '../../../connection-Dzkqj18h.cjs';
3
+ import { a as WebSocketConnection } from '../../../connection-CS00EWuS.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-BR0DZaWi.cjs';
6
+ import { c as ProvidedServerTransportOptions } from '../../../transport-D3jzhFSi.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-CHCzvZ9D.cjs';
11
+ import '../../../adapter-IGrG4KLL.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 { c as TransportClientId } from '../../../message-aABg0s5M.js';
2
2
  import { WebSocketServer } from 'ws';
3
- import { a as WebSocketConnection } from '../../../connection-C2lYgRh0.js';
3
+ import { a as WebSocketConnection } from '../../../connection-DU9v3y8a.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-uNzkzIRh.js';
6
+ import { c as ProvidedServerTransportOptions } from '../../../transport-BOL2p5s-.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-uF0cBM7z.js';
11
+ import '../../../adapter-CgF7vQPu.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-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/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.0";
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;
@@ -1696,6 +1765,17 @@ var ClientTransport = class extends Transport {
1696
1765
  {
1697
1766
  onSessionGracePeriodElapsed: () => {
1698
1767
  this.onSessionGracePeriodElapsed(session);
1768
+ },
1769
+ onMessageSendFailure: (msg, reason) => {
1770
+ this.log?.error(`failed to send message: ${reason}`, {
1771
+ ...session.loggingMetadata,
1772
+ transportMessage: msg
1773
+ });
1774
+ this.protocolError({
1775
+ type: ProtocolError.MessageSendFailure,
1776
+ message: reason
1777
+ });
1778
+ this.deleteSession(session, { unhealthy: true });
1699
1779
  }
1700
1780
  },
1701
1781
  this.options,
@@ -1760,6 +1840,17 @@ var ClientTransport = class extends Transport {
1760
1840
  },
1761
1841
  onSessionGracePeriodElapsed: () => {
1762
1842
  this.onSessionGracePeriodElapsed(handshakingSession);
1843
+ },
1844
+ onMessageSendFailure: (msg, reason) => {
1845
+ this.log?.error(`failed to send message: ${reason}`, {
1846
+ ...handshakingSession.loggingMetadata,
1847
+ transportMessage: msg
1848
+ });
1849
+ this.protocolError({
1850
+ type: ProtocolError.MessageSendFailure,
1851
+ message: reason
1852
+ });
1853
+ this.deleteSession(handshakingSession, { unhealthy: true });
1763
1854
  }
1764
1855
  }
1765
1856
  );
@@ -1921,6 +2012,17 @@ var ClientTransport = class extends Transport {
1921
2012
  },
1922
2013
  onSessionGracePeriodElapsed: () => {
1923
2014
  this.onSessionGracePeriodElapsed(backingOffSession);
2015
+ },
2016
+ onMessageSendFailure: (msg, reason) => {
2017
+ this.log?.error(`failed to send message: ${reason}`, {
2018
+ ...backingOffSession.loggingMetadata,
2019
+ transportMessage: msg
2020
+ });
2021
+ this.protocolError({
2022
+ type: ProtocolError.MessageSendFailure,
2023
+ message: reason
2024
+ });
2025
+ this.deleteSession(backingOffSession, { unhealthy: true });
1924
2026
  }
1925
2027
  }
1926
2028
  );
@@ -1984,6 +2086,17 @@ var ClientTransport = class extends Transport {
1984
2086
  },
1985
2087
  onSessionGracePeriodElapsed: () => {
1986
2088
  this.onSessionGracePeriodElapsed(connectingSession);
2089
+ },
2090
+ onMessageSendFailure: (msg, reason) => {
2091
+ this.log?.error(`failed to send message: ${reason}`, {
2092
+ ...connectingSession.loggingMetadata,
2093
+ transportMessage: msg
2094
+ });
2095
+ this.protocolError({
2096
+ type: ProtocolError.MessageSendFailure,
2097
+ message: reason
2098
+ });
2099
+ this.deleteSession(connectingSession, { unhealthy: true });
1987
2100
  }
1988
2101
  }
1989
2102
  );
@@ -2314,6 +2427,17 @@ var ServerTransport = class extends Transport {
2314
2427
  {
2315
2428
  onSessionGracePeriodElapsed: () => {
2316
2429
  this.onSessionGracePeriodElapsed(noConnectionSession);
2430
+ },
2431
+ onMessageSendFailure: (msg2, reason) => {
2432
+ this.log?.error(`failed to send message: ${reason}`, {
2433
+ ...noConnectionSession.loggingMetadata,
2434
+ transportMessage: msg2
2435
+ });
2436
+ this.protocolError({
2437
+ type: ProtocolError.MessageSendFailure,
2438
+ message: reason
2439
+ });
2440
+ this.deleteSession(noConnectionSession, { unhealthy: true });
2317
2441
  }
2318
2442
  }
2319
2443
  );