@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,5 +1,5 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-491d8c32.js';
2
- export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-491d8c32.js';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-6140f578.js';
2
+ export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-6140f578.js';
3
3
  import { Static } from '@sinclair/typebox';
4
4
  import { Pushable } from 'it-pushable';
5
5
  import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-154a0bb2.js';
@@ -8,7 +8,7 @@ import { S as ServerTransport } from '../server-1f5eb427.js';
8
8
  import '../message-ff78a233.js';
9
9
  import '@sinclair/typebox/value';
10
10
  import '@opentelemetry/api';
11
- import '../client-1894a9c9.js';
11
+ import '../client-6c67339a.js';
12
12
  import '@sinclair/typebox/errors';
13
13
  import '../types-3e5768ec.js';
14
14
 
@@ -46,6 +46,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
46
46
  extendedContext?: Omit<ServiceContext, 'state'>;
47
47
  }>): Server<Services>;
48
48
 
49
- var version = "0.26.3";
49
+ var version = "0.26.5";
50
50
 
51
51
  export { PayloadType, version as RIVER_VERSION, Result, RiverError, Server, ServiceContext, createServer };
@@ -1,5 +1,5 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-491d8c32.js';
2
- export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-491d8c32.js';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-6140f578.js';
2
+ export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-6140f578.js';
3
3
  import { Static } from '@sinclair/typebox';
4
4
  import { Pushable } from 'it-pushable';
5
5
  import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-154a0bb2.js';
@@ -8,7 +8,7 @@ import { S as ServerTransport } from '../server-1f5eb427.js';
8
8
  import '../message-ff78a233.js';
9
9
  import '@sinclair/typebox/value';
10
10
  import '@opentelemetry/api';
11
- import '../client-1894a9c9.js';
11
+ import '../client-6c67339a.js';
12
12
  import '@sinclair/typebox/errors';
13
13
  import '../types-3e5768ec.js';
14
14
 
@@ -46,6 +46,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
46
46
  extendedContext?: Omit<ServiceContext, 'state'>;
47
47
  }>): Server<Services>;
48
48
 
49
- var version = "0.26.3";
49
+ var version = "0.26.5";
50
50
 
51
51
  export { PayloadType, version as RIVER_VERSION, Result, RiverError, Server, ServiceContext, createServer };
@@ -10,10 +10,10 @@ import {
10
10
  createServer,
11
11
  createServerHandshakeOptions,
12
12
  serializeSchema
13
- } from "../chunk-3JCZNGF7.js";
13
+ } from "../chunk-FA2IRWCM.js";
14
14
  import {
15
15
  version
16
- } from "../chunk-MZELCWJK.js";
16
+ } from "../chunk-7KB7DHFZ.js";
17
17
  export {
18
18
  Err,
19
19
  Ok,
@@ -2,7 +2,7 @@ import { Static, TObject, TUnion, TString, TSchema, TNever, TLiteral } from '@si
2
2
  import { Pushable } from 'it-pushable';
3
3
  import { C as Connection, p as ClientHandshakeOptions, v as ServiceContextWithTransportInfo, o as ServiceContext } from './handshake-154a0bb2.js';
4
4
  import { c as TransportClientId } from './message-ff78a233.js';
5
- import { C as ClientTransport } from './client-1894a9c9.js';
5
+ import { C as ClientTransport } from './client-6c67339a.js';
6
6
 
7
7
  type AsyncIter<T> = AsyncGenerator<T, T>;
8
8
  /**
@@ -75,10 +75,7 @@ var ControlMessageHandshakeRequestSchema = import_typebox.Type.Object({
75
75
  expectedSessionState: import_typebox.Type.Object({
76
76
  // what the client expects the server to send next
77
77
  nextExpectedSeq: import_typebox.Type.Integer(),
78
- // TODO: remove optional once we know all servers
79
- // are nextSentSeq here
80
- // what the server expects the client to send next
81
- nextSentSeq: import_typebox.Type.Optional(import_typebox.Type.Integer())
78
+ nextSentSeq: import_typebox.Type.Integer()
82
79
  }),
83
80
  metadata: import_typebox.Type.Optional(import_typebox.Type.Unknown())
84
81
  });
@@ -114,9 +111,7 @@ var ControlMessageHandshakeResponseSchema = import_typebox.Type.Object({
114
111
  import_typebox.Type.Object({
115
112
  ok: import_typebox.Type.Literal(false),
116
113
  reason: import_typebox.Type.String(),
117
- // TODO: remove optional once we know all servers
118
- // are sending code here
119
- code: import_typebox.Type.Optional(HandshakeErrorResponseCodes)
114
+ code: HandshakeErrorResponseCodes
120
115
  })
121
116
  ])
122
117
  });
@@ -575,9 +570,6 @@ var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
575
570
  super(props);
576
571
  this.connPromise = props.connPromise;
577
572
  this.listeners = props.listeners;
578
- this.connectionTimeout = setTimeout(() => {
579
- this.listeners.onConnectionTimeout();
580
- }, this.options.connectionTimeoutMs);
581
573
  this.connPromise.then(
582
574
  (conn) => {
583
575
  if (this._isConsumed)
@@ -590,16 +582,21 @@ var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
590
582
  this.listeners.onConnectionFailed(err);
591
583
  }
592
584
  );
585
+ this.connectionTimeout = setTimeout(() => {
586
+ this.listeners.onConnectionTimeout();
587
+ }, this.options.connectionTimeoutMs);
593
588
  }
594
589
  // close a pending connection if it resolves, ignore errors if the promise
595
590
  // ends up rejected anyways
596
591
  bestEffortClose() {
597
- void this.connPromise.then((conn) => {
592
+ const logger = this.log;
593
+ const metadata = this.loggingMetadata;
594
+ this.connPromise.then((conn) => {
598
595
  conn.close();
599
- this.log?.info(
596
+ logger?.info(
600
597
  "connection eventually resolved but session has transitioned, closed connection",
601
598
  {
602
- ...this.loggingMetadata,
599
+ ...metadata,
603
600
  ...conn.loggingMetadata
604
601
  }
605
602
  );
@@ -634,7 +631,7 @@ var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
634
631
  var import_api = require("@opentelemetry/api");
635
632
 
636
633
  // package.json
637
- var version = "0.26.3";
634
+ var version = "0.26.5";
638
635
 
639
636
  // tracing/index.ts
640
637
  function getPropagationContext(ctx) {
@@ -796,13 +793,13 @@ var SessionConnected = class extends IdentifiedSession {
796
793
  this.conn.addCloseListener(this.listeners.onConnectionClosed);
797
794
  this.conn.addErrorListener(this.listeners.onConnectionErrored);
798
795
  if (this.sendBuffer.length > 0) {
799
- this.log?.debug(
800
- `sending ${this.sendBuffer.length} buffered messages`,
796
+ this.log?.info(
797
+ `sending ${this.sendBuffer.length} buffered messages, starting at seq ${this.nextSeq()}`,
801
798
  this.loggingMetadata
802
799
  );
803
- }
804
- for (const msg of this.sendBuffer) {
805
- this.conn.send(this.options.codec.toBuffer(msg));
800
+ for (const msg of this.sendBuffer) {
801
+ this.conn.send(this.options.codec.toBuffer(msg));
802
+ }
806
803
  }
807
804
  this.isActivelyHeartbeating = false;
808
805
  this.heartbeatHandle = setInterval(() => {
@@ -1533,10 +1530,10 @@ var ClientTransport = class extends Transport {
1533
1530
  return;
1534
1531
  }
1535
1532
  if (!msg.payload.status.ok) {
1536
- const retriable = msg.payload.status.code ? import_value2.Value.Check(
1533
+ const retriable = import_value2.Value.Check(
1537
1534
  HandshakeErrorRetriableResponseCodes,
1538
1535
  msg.payload.status.code
1539
- ) : false;
1536
+ );
1540
1537
  const reason = `handshake failed: ${msg.payload.status.reason}`;
1541
1538
  const to = session.to;
1542
1539
  this.rejectHandshakeResponse(session, reason, {
@@ -1634,22 +1631,7 @@ var ClientTransport = class extends Transport {
1634
1631
  backoffMs,
1635
1632
  {
1636
1633
  onBackoffFinished: () => {
1637
- const reconnectPromise = tracing_default.startActiveSpan(
1638
- "connect",
1639
- async (span) => {
1640
- try {
1641
- return await this.createNewOutgoingConnection(to);
1642
- } catch (err) {
1643
- const errStr = coerceErrorString(err);
1644
- span.recordException(errStr);
1645
- span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
1646
- throw err;
1647
- } finally {
1648
- span.end();
1649
- }
1650
- }
1651
- );
1652
- this.onBackoffFinished(backingOffSession, reconnectPromise);
1634
+ this.onBackoffFinished(backingOffSession);
1653
1635
  },
1654
1636
  onSessionGracePeriodElapsed: () => {
1655
1637
  this.onSessionGracePeriodElapsed(backingOffSession);
@@ -1658,7 +1640,19 @@ var ClientTransport = class extends Transport {
1658
1640
  );
1659
1641
  this.updateSession(backingOffSession);
1660
1642
  }
1661
- onBackoffFinished(session, connPromise) {
1643
+ onBackoffFinished(session) {
1644
+ const connPromise = tracing_default.startActiveSpan("connect", async (span) => {
1645
+ try {
1646
+ return await this.createNewOutgoingConnection(session.to);
1647
+ } catch (err) {
1648
+ const errStr = coerceErrorString(err);
1649
+ span.recordException(errStr);
1650
+ span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
1651
+ throw err;
1652
+ } finally {
1653
+ span.end();
1654
+ }
1655
+ });
1662
1656
  const connectingSession = ClientSessionStateGraph.transition.BackingOffToConnecting(
1663
1657
  session,
1664
1658
  connPromise,
@@ -1666,7 +1660,10 @@ var ClientTransport = class extends Transport {
1666
1660
  onConnectionEstablished: (conn) => {
1667
1661
  this.log?.debug(
1668
1662
  `connection to ${connectingSession.to} established`,
1669
- connectingSession.loggingMetadata
1663
+ {
1664
+ ...conn.loggingMetadata,
1665
+ ...connectingSession.loggingMetadata
1666
+ }
1670
1667
  );
1671
1668
  this.onConnectionEstablished(connectingSession, conn);
1672
1669
  },