@replit/river 0.26.3 → 0.26.5

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 (43) hide show
  1. package/dist/{chunk-MZELCWJK.js → chunk-7KB7DHFZ.js} +4 -9
  2. package/dist/chunk-7KB7DHFZ.js.map +1 -0
  3. package/dist/{chunk-X35QRIA5.js → chunk-AZ3ILPXP.js} +5 -5
  4. package/dist/chunk-AZ3ILPXP.js.map +1 -0
  5. package/dist/{chunk-3JCZNGF7.js → chunk-FA2IRWCM.js} +2 -2
  6. package/dist/{chunk-JI6FFDY5.js → chunk-IPOUVVKT.js} +3 -3
  7. package/dist/{chunk-BB2E5L4U.js → chunk-PZEYFHAB.js} +24 -24
  8. package/dist/chunk-PZEYFHAB.js.map +1 -0
  9. package/dist/{chunk-ZY2HYJ5Y.js → chunk-QEWSUVWV.js} +2 -2
  10. package/dist/{chunk-ZY2HYJ5Y.js.map → chunk-QEWSUVWV.js.map} +1 -1
  11. package/dist/{chunk-OCL2FUTQ.js → chunk-XRZ52TYH.js} +15 -13
  12. package/dist/{chunk-OCL2FUTQ.js.map → chunk-XRZ52TYH.js.map} +1 -1
  13. package/dist/{client-1894a9c9.d.ts → client-6c67339a.d.ts} +1 -1
  14. package/dist/router/index.cjs +3 -8
  15. package/dist/router/index.cjs.map +1 -1
  16. package/dist/router/index.d.cts +4 -4
  17. package/dist/router/index.d.ts +4 -4
  18. package/dist/router/index.js +2 -2
  19. package/dist/{services-491d8c32.d.ts → services-6140f578.d.ts} +1 -1
  20. package/dist/transport/impls/ws/client.cjs +36 -39
  21. package/dist/transport/impls/ws/client.cjs.map +1 -1
  22. package/dist/transport/impls/ws/client.d.cts +1 -1
  23. package/dist/transport/impls/ws/client.d.ts +1 -1
  24. package/dist/transport/impls/ws/client.js +5 -5
  25. package/dist/transport/impls/ws/server.cjs +17 -20
  26. package/dist/transport/impls/ws/server.cjs.map +1 -1
  27. package/dist/transport/impls/ws/server.js +5 -5
  28. package/dist/transport/index.cjs +37 -40
  29. package/dist/transport/index.cjs.map +1 -1
  30. package/dist/transport/index.d.cts +1 -1
  31. package/dist/transport/index.d.ts +1 -1
  32. package/dist/transport/index.js +5 -5
  33. package/dist/util/testHelpers.cjs +16 -19
  34. package/dist/util/testHelpers.cjs.map +1 -1
  35. package/dist/util/testHelpers.d.cts +2 -2
  36. package/dist/util/testHelpers.d.ts +2 -2
  37. package/dist/util/testHelpers.js +3 -3
  38. package/package.json +1 -1
  39. package/dist/chunk-BB2E5L4U.js.map +0 -1
  40. package/dist/chunk-MZELCWJK.js.map +0 -1
  41. package/dist/chunk-X35QRIA5.js.map +0 -1
  42. /package/dist/{chunk-3JCZNGF7.js.map → chunk-FA2IRWCM.js.map} +0 -0
  43. /package/dist/{chunk-JI6FFDY5.js.map → chunk-IPOUVVKT.js.map} +0 -0
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  ServerTransport
3
- } from "../../../chunk-X35QRIA5.js";
3
+ } from "../../../chunk-AZ3ILPXP.js";
4
4
  import {
5
5
  WebSocketConnection
6
- } from "../../../chunk-ZY2HYJ5Y.js";
7
- import "../../../chunk-JI6FFDY5.js";
6
+ } from "../../../chunk-QEWSUVWV.js";
7
+ import "../../../chunk-IPOUVVKT.js";
8
8
  import "../../../chunk-TAH2GVTJ.js";
9
- import "../../../chunk-OCL2FUTQ.js";
10
- import "../../../chunk-MZELCWJK.js";
9
+ import "../../../chunk-XRZ52TYH.js";
10
+ import "../../../chunk-7KB7DHFZ.js";
11
11
  import "../../../chunk-4PVU7J25.js";
12
12
 
13
13
  // transport/impls/ws/server.ts
@@ -246,10 +246,7 @@ var ControlMessageHandshakeRequestSchema = import_typebox.Type.Object({
246
246
  expectedSessionState: import_typebox.Type.Object({
247
247
  // what the client expects the server to send next
248
248
  nextExpectedSeq: import_typebox.Type.Integer(),
249
- // TODO: remove optional once we know all servers
250
- // are nextSentSeq here
251
- // what the server expects the client to send next
252
- nextSentSeq: import_typebox.Type.Optional(import_typebox.Type.Integer())
249
+ nextSentSeq: import_typebox.Type.Integer()
253
250
  }),
254
251
  metadata: import_typebox.Type.Optional(import_typebox.Type.Unknown())
255
252
  });
@@ -285,9 +282,7 @@ var ControlMessageHandshakeResponseSchema = import_typebox.Type.Object({
285
282
  import_typebox.Type.Object({
286
283
  ok: import_typebox.Type.Literal(false),
287
284
  reason: import_typebox.Type.String(),
288
- // TODO: remove optional once we know all servers
289
- // are sending code here
290
- code: import_typebox.Type.Optional(HandshakeErrorResponseCodes)
285
+ code: HandshakeErrorResponseCodes
291
286
  })
292
287
  ])
293
288
  });
@@ -540,9 +535,6 @@ var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
540
535
  super(props);
541
536
  this.connPromise = props.connPromise;
542
537
  this.listeners = props.listeners;
543
- this.connectionTimeout = setTimeout(() => {
544
- this.listeners.onConnectionTimeout();
545
- }, this.options.connectionTimeoutMs);
546
538
  this.connPromise.then(
547
539
  (conn) => {
548
540
  if (this._isConsumed)
@@ -555,16 +547,21 @@ var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
555
547
  this.listeners.onConnectionFailed(err);
556
548
  }
557
549
  );
550
+ this.connectionTimeout = setTimeout(() => {
551
+ this.listeners.onConnectionTimeout();
552
+ }, this.options.connectionTimeoutMs);
558
553
  }
559
554
  // close a pending connection if it resolves, ignore errors if the promise
560
555
  // ends up rejected anyways
561
556
  bestEffortClose() {
562
- void this.connPromise.then((conn) => {
557
+ const logger = this.log;
558
+ const metadata = this.loggingMetadata;
559
+ this.connPromise.then((conn) => {
563
560
  conn.close();
564
- this.log?.info(
561
+ logger?.info(
565
562
  "connection eventually resolved but session has transitioned, closed connection",
566
563
  {
567
- ...this.loggingMetadata,
564
+ ...metadata,
568
565
  ...conn.loggingMetadata
569
566
  }
570
567
  );
@@ -599,7 +596,7 @@ var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
599
596
  var import_api = require("@opentelemetry/api");
600
597
 
601
598
  // package.json
602
- var version = "0.26.3";
599
+ var version = "0.26.5";
603
600
 
604
601
  // tracing/index.ts
605
602
  function getPropagationContext(ctx) {
@@ -761,13 +758,13 @@ var SessionConnected = class extends IdentifiedSession {
761
758
  this.conn.addCloseListener(this.listeners.onConnectionClosed);
762
759
  this.conn.addErrorListener(this.listeners.onConnectionErrored);
763
760
  if (this.sendBuffer.length > 0) {
764
- this.log?.debug(
765
- `sending ${this.sendBuffer.length} buffered messages`,
761
+ this.log?.info(
762
+ `sending ${this.sendBuffer.length} buffered messages, starting at seq ${this.nextSeq()}`,
766
763
  this.loggingMetadata
767
764
  );
768
- }
769
- for (const msg of this.sendBuffer) {
770
- this.conn.send(this.options.codec.toBuffer(msg));
765
+ for (const msg of this.sendBuffer) {
766
+ this.conn.send(this.options.codec.toBuffer(msg));
767
+ }
771
768
  }
772
769
  this.isActivelyHeartbeating = false;
773
770
  this.heartbeatHandle = setInterval(() => {
@@ -1568,10 +1565,10 @@ var ClientTransport = class extends Transport {
1568
1565
  return;
1569
1566
  }
1570
1567
  if (!msg.payload.status.ok) {
1571
- const retriable = msg.payload.status.code ? import_value2.Value.Check(
1568
+ const retriable = import_value2.Value.Check(
1572
1569
  HandshakeErrorRetriableResponseCodes,
1573
1570
  msg.payload.status.code
1574
- ) : false;
1571
+ );
1575
1572
  const reason = `handshake failed: ${msg.payload.status.reason}`;
1576
1573
  const to = session.to;
1577
1574
  this.rejectHandshakeResponse(session, reason, {
@@ -1669,22 +1666,7 @@ var ClientTransport = class extends Transport {
1669
1666
  backoffMs,
1670
1667
  {
1671
1668
  onBackoffFinished: () => {
1672
- const reconnectPromise = tracing_default.startActiveSpan(
1673
- "connect",
1674
- async (span) => {
1675
- try {
1676
- return await this.createNewOutgoingConnection(to);
1677
- } catch (err) {
1678
- const errStr = coerceErrorString(err);
1679
- span.recordException(errStr);
1680
- span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
1681
- throw err;
1682
- } finally {
1683
- span.end();
1684
- }
1685
- }
1686
- );
1687
- this.onBackoffFinished(backingOffSession, reconnectPromise);
1669
+ this.onBackoffFinished(backingOffSession);
1688
1670
  },
1689
1671
  onSessionGracePeriodElapsed: () => {
1690
1672
  this.onSessionGracePeriodElapsed(backingOffSession);
@@ -1693,7 +1675,19 @@ var ClientTransport = class extends Transport {
1693
1675
  );
1694
1676
  this.updateSession(backingOffSession);
1695
1677
  }
1696
- onBackoffFinished(session, connPromise) {
1678
+ onBackoffFinished(session) {
1679
+ const connPromise = tracing_default.startActiveSpan("connect", async (span) => {
1680
+ try {
1681
+ return await this.createNewOutgoingConnection(session.to);
1682
+ } catch (err) {
1683
+ const errStr = coerceErrorString(err);
1684
+ span.recordException(errStr);
1685
+ span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
1686
+ throw err;
1687
+ } finally {
1688
+ span.end();
1689
+ }
1690
+ });
1697
1691
  const connectingSession = ClientSessionStateGraph.transition.BackingOffToConnecting(
1698
1692
  session,
1699
1693
  connPromise,
@@ -1701,7 +1695,10 @@ var ClientTransport = class extends Transport {
1701
1695
  onConnectionEstablished: (conn) => {
1702
1696
  this.log?.debug(
1703
1697
  `connection to ${connectingSession.to} established`,
1704
- connectingSession.loggingMetadata
1698
+ {
1699
+ ...conn.loggingMetadata,
1700
+ ...connectingSession.loggingMetadata
1701
+ }
1705
1702
  );
1706
1703
  this.onConnectionEstablished(connectingSession, conn);
1707
1704
  },
@@ -1994,7 +1991,7 @@ var ServerTransport = class extends Transport {
1994
1991
  }
1995
1992
  let connectCase = "new session";
1996
1993
  const clientNextExpectedSeq = msg.payload.expectedSessionState.nextExpectedSeq;
1997
- const clientNextSentSeq = msg.payload.expectedSessionState.nextSentSeq ?? 0;
1994
+ const clientNextSentSeq = msg.payload.expectedSessionState.nextSentSeq;
1998
1995
  if (this.options.enableTransparentSessionReconnects && oldSession && oldSession.id === msg.payload.sessionId) {
1999
1996
  connectCase = "transparent reconnection";
2000
1997
  const ourNextSeq = oldSession.nextSeq();