@replit/river 0.15.2 → 0.15.4

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 (33) hide show
  1. package/dist/{builder-ebd945c0.d.ts → builder-4d392f6c.d.ts} +1 -1
  2. package/dist/{chunk-B7VTDQR7.js → chunk-5TYDJKOP.js} +13 -10
  3. package/dist/{chunk-ZRB6IKPV.js → chunk-DEYIG5LG.js} +1 -1
  4. package/dist/{chunk-UJHTHOTT.js → chunk-QF3XH65C.js} +1 -1
  5. package/dist/{connection-10a24478.d.ts → connection-94896f3b.d.ts} +1 -1
  6. package/dist/{connection-f4492948.d.ts → connection-99346822.d.ts} +1 -1
  7. package/dist/{index-bbccacef.d.ts → index-2e402bb8.d.ts} +5 -5
  8. package/dist/router/index.d.cts +3 -3
  9. package/dist/router/index.d.ts +3 -3
  10. package/dist/transport/impls/uds/client.cjs +13 -10
  11. package/dist/transport/impls/uds/client.d.cts +2 -2
  12. package/dist/transport/impls/uds/client.d.ts +2 -2
  13. package/dist/transport/impls/uds/client.js +2 -2
  14. package/dist/transport/impls/uds/server.cjs +8 -7
  15. package/dist/transport/impls/uds/server.d.cts +2 -2
  16. package/dist/transport/impls/uds/server.d.ts +2 -2
  17. package/dist/transport/impls/uds/server.js +2 -2
  18. package/dist/transport/impls/ws/client.cjs +13 -10
  19. package/dist/transport/impls/ws/client.d.cts +2 -2
  20. package/dist/transport/impls/ws/client.d.ts +2 -2
  21. package/dist/transport/impls/ws/client.js +2 -2
  22. package/dist/transport/impls/ws/server.cjs +8 -7
  23. package/dist/transport/impls/ws/server.d.cts +3 -3
  24. package/dist/transport/impls/ws/server.d.ts +3 -3
  25. package/dist/transport/impls/ws/server.js +2 -2
  26. package/dist/transport/index.cjs +13 -10
  27. package/dist/transport/index.d.cts +1 -1
  28. package/dist/transport/index.d.ts +1 -1
  29. package/dist/transport/index.js +1 -1
  30. package/dist/util/testHelpers.d.cts +2 -2
  31. package/dist/util/testHelpers.d.ts +2 -2
  32. package/dist/util/testHelpers.js +1 -1
  33. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { TObject, TUnion, TString, TSchema, TNever, TLiteral, Static } from '@sinclair/typebox';
2
2
  import { Pushable } from 'it-pushable';
3
- import { b as TransportClientId, e as Session, C as Connection } from './index-bbccacef.js';
3
+ import { b as TransportClientId, e as Session, C as Connection } from './index-2e402bb8.js';
4
4
 
5
5
  /**
6
6
  * The context for services/procedures. This is used only on
@@ -324,14 +324,15 @@ var defaultTransportOptions = {
324
324
  sessionDisconnectGraceMs: 5e3,
325
325
  codec: NaiveJsonCodec
326
326
  };
327
+ var defaultConnectionRetryOptions = {
328
+ baseIntervalMs: 250,
329
+ maxJitterMs: 200,
330
+ maxBackoffMs: 32e3,
331
+ attemptBudgetCapacity: 15,
332
+ budgetRestoreIntervalMs: 200
333
+ };
327
334
  var defaultClientTransportOptions = {
328
- connectionRetryOptions: {
329
- baseIntervalMs: 250,
330
- maxJitterMs: 200,
331
- maxBackoffMs: 32e3,
332
- attemptBudgetCapacity: 15,
333
- budgetRestoreIntervalMs: 200
334
- },
335
+ connectionRetryOptions: defaultConnectionRetryOptions,
335
336
  ...defaultTransportOptions
336
337
  };
337
338
  var Transport = class {
@@ -705,6 +706,7 @@ var ClientTransport = class extends Transport {
705
706
  log?.debug(
706
707
  `${this.clientId} -- handshake from ${parsed.from} ok (instance: ${instanceId})`
707
708
  );
709
+ this.retryBudget.startRestoringBudget(parsed.from);
708
710
  return { instanceId, from: parsed.from };
709
711
  }
710
712
  /**
@@ -721,10 +723,9 @@ var ClientTransport = class extends Transport {
721
723
  }
722
724
  let reconnectPromise = this.inflightConnectionPromises.get(to);
723
725
  if (!reconnectPromise) {
724
- log?.info(`${this.clientId} -- attempting connection to ${to}`);
725
726
  const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
726
727
  if (!this.retryBudget.hasBudget(to)) {
727
- const errMsg = `not attempting to connect to ${to}, retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
728
+ const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
728
729
  log?.warn(`${this.clientId} -- ${errMsg}`);
729
730
  this.protocolError(ProtocolError.RetriesExceeded, errMsg);
730
731
  return;
@@ -734,6 +735,9 @@ var ClientTransport = class extends Transport {
734
735
  if (backoffMs > 0) {
735
736
  sleep = new Promise((resolve) => setTimeout(resolve, backoffMs));
736
737
  }
738
+ log?.info(
739
+ `${this.clientId} -- attempting connection to ${to} (${backoffMs} backoff)`
740
+ );
737
741
  this.retryBudget.consumeBudget(to);
738
742
  reconnectPromise = sleep.then(() => {
739
743
  if (!canProceedWithConnection()) {
@@ -747,7 +751,6 @@ var ClientTransport = class extends Transport {
747
751
  conn.close();
748
752
  throw new Error("transport state is no longer open");
749
753
  }
750
- this.retryBudget.startRestoringBudget(to);
751
754
  this.sendHandshake(to, conn);
752
755
  return conn;
753
756
  });
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Connection
3
- } from "./chunk-B7VTDQR7.js";
3
+ } from "./chunk-5TYDJKOP.js";
4
4
 
5
5
  // transport/impls/ws/connection.ts
6
6
  var WebSocketConnection = class extends Connection {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Connection
3
- } from "./chunk-B7VTDQR7.js";
3
+ } from "./chunk-5TYDJKOP.js";
4
4
 
5
5
  // transport/transforms/messageFraming.ts
6
6
  import { Transform } from "node:stream";
@@ -1,4 +1,4 @@
1
- import { C as Connection } from './index-bbccacef.js';
1
+ import { C as Connection } from './index-2e402bb8.js';
2
2
  import { Socket } from 'node:net';
3
3
  import stream, { Transform, TransformCallback, TransformOptions } from 'node:stream';
4
4
 
@@ -1,5 +1,5 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { C as Connection } from './index-bbccacef.js';
2
+ import { C as Connection } from './index-2e402bb8.js';
3
3
 
4
4
  declare class WebSocketConnection extends Connection {
5
5
  ws: WebSocket;
@@ -310,12 +310,12 @@ declare class LeakyBucketRateLimit {
310
310
  type TransportStatus = 'open' | 'closed' | 'destroyed';
311
311
  type ProvidedTransportOptions = Partial<SessionOptions>;
312
312
  type TransportOptions = Required<ProvidedTransportOptions>;
313
- interface ProvidedClientTransportOptions extends ProvidedTransportOptions {
313
+ type ProvidedClientTransportOptions = {
314
314
  connectionRetryOptions?: Partial<ConnectionRetryOptions>;
315
- }
316
- interface ClientTransportOptions extends Required<ProvidedClientTransportOptions> {
315
+ } & ProvidedTransportOptions;
316
+ type ClientTransportOptions = SessionOptions & {
317
317
  connectionRetryOptions: ConnectionRetryOptions;
318
- }
318
+ };
319
319
  /**
320
320
  * Transports manage the lifecycle (creation/deletion) of sessions and connections. Its responsibilities include:
321
321
  *
@@ -494,7 +494,7 @@ declare abstract class ClientTransport<ConnType extends Connection> extends Tran
494
494
  close(): void;
495
495
  }
496
496
  declare abstract class ServerTransport<ConnType extends Connection> extends Transport<ConnType> {
497
- constructor(clientId: TransportClientId, providedOptions?: Omit<Partial<ProvidedTransportOptions>, 'connectionRetryOptions'>);
497
+ constructor(clientId: TransportClientId, providedOptions?: ProvidedTransportOptions);
498
498
  protected handleConnection(conn: ConnType): void;
499
499
  receiveHandshakeRequestMessage(data: Uint8Array, conn: ConnType): false | {
500
500
  instanceId: string;
@@ -1,6 +1,6 @@
1
- import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-ebd945c0.js';
2
- export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-ebd945c0.js';
3
- import { S as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-bbccacef.js';
1
+ import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-4d392f6c.js';
2
+ export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-4d392f6c.js';
3
+ import { S as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-2e402bb8.js';
4
4
  import { Pushable } from 'it-pushable';
5
5
  import { Static } from '@sinclair/typebox';
6
6
  import '../types-3e5768ec.js';
@@ -1,6 +1,6 @@
1
- import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-ebd945c0.js';
2
- export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-ebd945c0.js';
3
- import { S as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-bbccacef.js';
1
+ import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-4d392f6c.js';
2
+ export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-4d392f6c.js';
3
+ import { S as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-2e402bb8.js';
4
4
  import { Pushable } from 'it-pushable';
5
5
  import { Static } from '@sinclair/typebox';
6
6
  import '../types-3e5768ec.js';
@@ -563,14 +563,15 @@ var defaultTransportOptions = {
563
563
  sessionDisconnectGraceMs: 5e3,
564
564
  codec: NaiveJsonCodec
565
565
  };
566
+ var defaultConnectionRetryOptions = {
567
+ baseIntervalMs: 250,
568
+ maxJitterMs: 200,
569
+ maxBackoffMs: 32e3,
570
+ attemptBudgetCapacity: 15,
571
+ budgetRestoreIntervalMs: 200
572
+ };
566
573
  var defaultClientTransportOptions = {
567
- connectionRetryOptions: {
568
- baseIntervalMs: 250,
569
- maxJitterMs: 200,
570
- maxBackoffMs: 32e3,
571
- attemptBudgetCapacity: 15,
572
- budgetRestoreIntervalMs: 200
573
- },
574
+ connectionRetryOptions: defaultConnectionRetryOptions,
574
575
  ...defaultTransportOptions
575
576
  };
576
577
  var Transport = class {
@@ -944,6 +945,7 @@ var ClientTransport = class extends Transport {
944
945
  log?.debug(
945
946
  `${this.clientId} -- handshake from ${parsed.from} ok (instance: ${instanceId})`
946
947
  );
948
+ this.retryBudget.startRestoringBudget(parsed.from);
947
949
  return { instanceId, from: parsed.from };
948
950
  }
949
951
  /**
@@ -960,10 +962,9 @@ var ClientTransport = class extends Transport {
960
962
  }
961
963
  let reconnectPromise = this.inflightConnectionPromises.get(to);
962
964
  if (!reconnectPromise) {
963
- log?.info(`${this.clientId} -- attempting connection to ${to}`);
964
965
  const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
965
966
  if (!this.retryBudget.hasBudget(to)) {
966
- const errMsg = `not attempting to connect to ${to}, retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
967
+ const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
967
968
  log?.warn(`${this.clientId} -- ${errMsg}`);
968
969
  this.protocolError(ProtocolError.RetriesExceeded, errMsg);
969
970
  return;
@@ -973,6 +974,9 @@ var ClientTransport = class extends Transport {
973
974
  if (backoffMs > 0) {
974
975
  sleep = new Promise((resolve) => setTimeout(resolve, backoffMs));
975
976
  }
977
+ log?.info(
978
+ `${this.clientId} -- attempting connection to ${to} (${backoffMs} backoff)`
979
+ );
976
980
  this.retryBudget.consumeBudget(to);
977
981
  reconnectPromise = sleep.then(() => {
978
982
  if (!canProceedWithConnection()) {
@@ -986,7 +990,6 @@ var ClientTransport = class extends Transport {
986
990
  conn.close();
987
991
  throw new Error("transport state is no longer open");
988
992
  }
989
- this.retryBudget.startRestoringBudget(to);
990
993
  this.sendHandshake(to, conn);
991
994
  return conn;
992
995
  });
@@ -1,5 +1,5 @@
1
- import { a as ClientTransport, c as ProvidedClientTransportOptions, b as TransportClientId } from '../../../index-bbccacef.js';
2
- import { U as UdsConnection } from '../../../connection-10a24478.js';
1
+ import { a as ClientTransport, c as ProvidedClientTransportOptions, b as TransportClientId } from '../../../index-2e402bb8.js';
2
+ import { U as UdsConnection } from '../../../connection-94896f3b.js';
3
3
  import '../../../types-3e5768ec.js';
4
4
  import '@sinclair/typebox';
5
5
  import 'node:net';
@@ -1,5 +1,5 @@
1
- import { a as ClientTransport, c as ProvidedClientTransportOptions, b as TransportClientId } from '../../../index-bbccacef.js';
2
- import { U as UdsConnection } from '../../../connection-10a24478.js';
1
+ import { a as ClientTransport, c as ProvidedClientTransportOptions, b as TransportClientId } from '../../../index-2e402bb8.js';
2
+ import { U as UdsConnection } from '../../../connection-94896f3b.js';
3
3
  import '../../../types-3e5768ec.js';
4
4
  import '@sinclair/typebox';
5
5
  import 'node:net';
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  UdsConnection
3
- } from "../../../chunk-UJHTHOTT.js";
3
+ } from "../../../chunk-QF3XH65C.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-B7VTDQR7.js";
6
+ } from "../../../chunk-5TYDJKOP.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import {
9
9
  log
@@ -403,14 +403,15 @@ var defaultTransportOptions = {
403
403
  sessionDisconnectGraceMs: 5e3,
404
404
  codec: NaiveJsonCodec
405
405
  };
406
+ var defaultConnectionRetryOptions = {
407
+ baseIntervalMs: 250,
408
+ maxJitterMs: 200,
409
+ maxBackoffMs: 32e3,
410
+ attemptBudgetCapacity: 15,
411
+ budgetRestoreIntervalMs: 200
412
+ };
406
413
  var defaultClientTransportOptions = {
407
- connectionRetryOptions: {
408
- baseIntervalMs: 250,
409
- maxJitterMs: 200,
410
- maxBackoffMs: 32e3,
411
- attemptBudgetCapacity: 15,
412
- budgetRestoreIntervalMs: 200
413
- },
414
+ connectionRetryOptions: defaultConnectionRetryOptions,
414
415
  ...defaultTransportOptions
415
416
  };
416
417
  var Transport = class {
@@ -1,6 +1,6 @@
1
1
  import { Server, Socket } from 'node:net';
2
- import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-bbccacef.js';
3
- import { U as UdsConnection } from '../../../connection-10a24478.js';
2
+ import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-2e402bb8.js';
3
+ import { U as UdsConnection } from '../../../connection-94896f3b.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
  import 'node:stream';
@@ -1,6 +1,6 @@
1
1
  import { Server, Socket } from 'node:net';
2
- import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-bbccacef.js';
3
- import { U as UdsConnection } from '../../../connection-10a24478.js';
2
+ import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-2e402bb8.js';
3
+ import { U as UdsConnection } from '../../../connection-94896f3b.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
  import 'node:stream';
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  UdsConnection
3
- } from "../../../chunk-UJHTHOTT.js";
3
+ } from "../../../chunk-QF3XH65C.js";
4
4
  import {
5
5
  ServerTransport
6
- } from "../../../chunk-B7VTDQR7.js";
6
+ } from "../../../chunk-5TYDJKOP.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import {
9
9
  log
@@ -467,14 +467,15 @@ var defaultTransportOptions = {
467
467
  sessionDisconnectGraceMs: 5e3,
468
468
  codec: NaiveJsonCodec
469
469
  };
470
+ var defaultConnectionRetryOptions = {
471
+ baseIntervalMs: 250,
472
+ maxJitterMs: 200,
473
+ maxBackoffMs: 32e3,
474
+ attemptBudgetCapacity: 15,
475
+ budgetRestoreIntervalMs: 200
476
+ };
470
477
  var defaultClientTransportOptions = {
471
- connectionRetryOptions: {
472
- baseIntervalMs: 250,
473
- maxJitterMs: 200,
474
- maxBackoffMs: 32e3,
475
- attemptBudgetCapacity: 15,
476
- budgetRestoreIntervalMs: 200
477
- },
478
+ connectionRetryOptions: defaultConnectionRetryOptions,
478
479
  ...defaultTransportOptions
479
480
  };
480
481
  var Transport = class {
@@ -848,6 +849,7 @@ var ClientTransport = class extends Transport {
848
849
  log?.debug(
849
850
  `${this.clientId} -- handshake from ${parsed.from} ok (instance: ${instanceId})`
850
851
  );
852
+ this.retryBudget.startRestoringBudget(parsed.from);
851
853
  return { instanceId, from: parsed.from };
852
854
  }
853
855
  /**
@@ -864,10 +866,9 @@ var ClientTransport = class extends Transport {
864
866
  }
865
867
  let reconnectPromise = this.inflightConnectionPromises.get(to);
866
868
  if (!reconnectPromise) {
867
- log?.info(`${this.clientId} -- attempting connection to ${to}`);
868
869
  const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
869
870
  if (!this.retryBudget.hasBudget(to)) {
870
- const errMsg = `not attempting to connect to ${to}, retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
871
+ const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
871
872
  log?.warn(`${this.clientId} -- ${errMsg}`);
872
873
  this.protocolError(ProtocolError.RetriesExceeded, errMsg);
873
874
  return;
@@ -877,6 +878,9 @@ var ClientTransport = class extends Transport {
877
878
  if (backoffMs > 0) {
878
879
  sleep = new Promise((resolve) => setTimeout(resolve, backoffMs));
879
880
  }
881
+ log?.info(
882
+ `${this.clientId} -- attempting connection to ${to} (${backoffMs} backoff)`
883
+ );
880
884
  this.retryBudget.consumeBudget(to);
881
885
  reconnectPromise = sleep.then(() => {
882
886
  if (!canProceedWithConnection()) {
@@ -890,7 +894,6 @@ var ClientTransport = class extends Transport {
890
894
  conn.close();
891
895
  throw new Error("transport state is no longer open");
892
896
  }
893
- this.retryBudget.startRestoringBudget(to);
894
897
  this.sendHandshake(to, conn);
895
898
  return conn;
896
899
  });
@@ -1,6 +1,6 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-bbccacef.js';
3
- import { W as WebSocketConnection } from '../../../connection-f4492948.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-2e402bb8.js';
3
+ import { W as WebSocketConnection } from '../../../connection-99346822.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-bbccacef.js';
3
- import { W as WebSocketConnection } from '../../../connection-f4492948.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-2e402bb8.js';
3
+ import { W as WebSocketConnection } from '../../../connection-99346822.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
 
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  WebSocketConnection
3
- } from "../../../chunk-ZRB6IKPV.js";
3
+ } from "../../../chunk-DEYIG5LG.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-B7VTDQR7.js";
6
+ } from "../../../chunk-5TYDJKOP.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import {
9
9
  log
@@ -403,14 +403,15 @@ var defaultTransportOptions = {
403
403
  sessionDisconnectGraceMs: 5e3,
404
404
  codec: NaiveJsonCodec
405
405
  };
406
+ var defaultConnectionRetryOptions = {
407
+ baseIntervalMs: 250,
408
+ maxJitterMs: 200,
409
+ maxBackoffMs: 32e3,
410
+ attemptBudgetCapacity: 15,
411
+ budgetRestoreIntervalMs: 200
412
+ };
406
413
  var defaultClientTransportOptions = {
407
- connectionRetryOptions: {
408
- baseIntervalMs: 250,
409
- maxJitterMs: 200,
410
- maxBackoffMs: 32e3,
411
- attemptBudgetCapacity: 15,
412
- budgetRestoreIntervalMs: 200
413
- },
414
+ connectionRetryOptions: defaultConnectionRetryOptions,
414
415
  ...defaultTransportOptions
415
416
  };
416
417
  var Transport = class {
@@ -1,13 +1,13 @@
1
- import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-bbccacef.js';
1
+ import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-2e402bb8.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-f4492948.js';
4
+ import { W as WebSocketConnection } from '../../../connection-99346822.js';
5
5
  import '../../../types-3e5768ec.js';
6
6
  import '@sinclair/typebox';
7
7
 
8
8
  declare class WebSocketServerTransport extends ServerTransport<WebSocketConnection> {
9
9
  wss: WebSocketServer;
10
- constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: Partial<ProvidedTransportOptions>);
10
+ constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: ProvidedTransportOptions);
11
11
  connectionHandler: (ws: WebSocket) => void;
12
12
  close(): void;
13
13
  }
@@ -1,13 +1,13 @@
1
- import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-bbccacef.js';
1
+ import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-2e402bb8.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-f4492948.js';
4
+ import { W as WebSocketConnection } from '../../../connection-99346822.js';
5
5
  import '../../../types-3e5768ec.js';
6
6
  import '@sinclair/typebox';
7
7
 
8
8
  declare class WebSocketServerTransport extends ServerTransport<WebSocketConnection> {
9
9
  wss: WebSocketServer;
10
- constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: Partial<ProvidedTransportOptions>);
10
+ constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: ProvidedTransportOptions);
11
11
  connectionHandler: (ws: WebSocket) => void;
12
12
  close(): void;
13
13
  }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  WebSocketConnection
3
- } from "../../../chunk-ZRB6IKPV.js";
3
+ } from "../../../chunk-DEYIG5LG.js";
4
4
  import {
5
5
  ServerTransport
6
- } from "../../../chunk-B7VTDQR7.js";
6
+ } from "../../../chunk-5TYDJKOP.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import "../../../chunk-H4BYJELI.js";
9
9
  import "../../../chunk-GZ7HCLLM.js";
@@ -498,14 +498,15 @@ var defaultTransportOptions = {
498
498
  sessionDisconnectGraceMs: 5e3,
499
499
  codec: NaiveJsonCodec
500
500
  };
501
+ var defaultConnectionRetryOptions = {
502
+ baseIntervalMs: 250,
503
+ maxJitterMs: 200,
504
+ maxBackoffMs: 32e3,
505
+ attemptBudgetCapacity: 15,
506
+ budgetRestoreIntervalMs: 200
507
+ };
501
508
  var defaultClientTransportOptions = {
502
- connectionRetryOptions: {
503
- baseIntervalMs: 250,
504
- maxJitterMs: 200,
505
- maxBackoffMs: 32e3,
506
- attemptBudgetCapacity: 15,
507
- budgetRestoreIntervalMs: 200
508
- },
509
+ connectionRetryOptions: defaultConnectionRetryOptions,
509
510
  ...defaultTransportOptions
510
511
  };
511
512
  var Transport = class {
@@ -879,6 +880,7 @@ var ClientTransport = class extends Transport {
879
880
  log?.debug(
880
881
  `${this.clientId} -- handshake from ${parsed.from} ok (instance: ${instanceId})`
881
882
  );
883
+ this.retryBudget.startRestoringBudget(parsed.from);
882
884
  return { instanceId, from: parsed.from };
883
885
  }
884
886
  /**
@@ -895,10 +897,9 @@ var ClientTransport = class extends Transport {
895
897
  }
896
898
  let reconnectPromise = this.inflightConnectionPromises.get(to);
897
899
  if (!reconnectPromise) {
898
- log?.info(`${this.clientId} -- attempting connection to ${to}`);
899
900
  const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
900
901
  if (!this.retryBudget.hasBudget(to)) {
901
- const errMsg = `not attempting to connect to ${to}, retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
902
+ const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
902
903
  log?.warn(`${this.clientId} -- ${errMsg}`);
903
904
  this.protocolError(ProtocolError.RetriesExceeded, errMsg);
904
905
  return;
@@ -908,6 +909,9 @@ var ClientTransport = class extends Transport {
908
909
  if (backoffMs > 0) {
909
910
  sleep = new Promise((resolve) => setTimeout(resolve, backoffMs));
910
911
  }
912
+ log?.info(
913
+ `${this.clientId} -- attempting connection to ${to} (${backoffMs} backoff)`
914
+ );
911
915
  this.retryBudget.consumeBudget(to);
912
916
  reconnectPromise = sleep.then(() => {
913
917
  if (!canProceedWithConnection()) {
@@ -921,7 +925,6 @@ var ClientTransport = class extends Transport {
921
925
  conn.close();
922
926
  throw new Error("transport state is no longer open");
923
927
  }
924
- this.retryBudget.startRestoringBudget(to);
925
928
  this.sendHandshake(to, conn);
926
929
  return conn;
927
930
  });
@@ -1,3 +1,3 @@
1
- export { a as ClientTransport, c as ClientTransportOptions, C as Connection, m as EventHandler, E as EventMap, l as EventTypes, O as OpaqueTransportMessage, h as OpaqueTransportMessageSchema, n as ProtocolError, o as ProtocolErrorType, d as ServerTransporOptions, S as ServerTransport, e as Session, T as Transport, b as TransportClientId, i as TransportMessage, g as TransportMessageSchema, f as TransportStatus, k as isStreamClose, j as isStreamOpen } from '../index-bbccacef.js';
1
+ export { a as ClientTransport, c as ClientTransportOptions, C as Connection, m as EventHandler, E as EventMap, l as EventTypes, O as OpaqueTransportMessage, h as OpaqueTransportMessageSchema, n as ProtocolError, o as ProtocolErrorType, S as ServerTransport, e as Session, T as Transport, b as TransportClientId, i as TransportMessage, g as TransportMessageSchema, d as TransportOptions, f as TransportStatus, k as isStreamClose, j as isStreamOpen } from '../index-2e402bb8.js';
2
2
  import '../types-3e5768ec.js';
3
3
  import '@sinclair/typebox';
@@ -1,3 +1,3 @@
1
- export { a as ClientTransport, c as ClientTransportOptions, C as Connection, m as EventHandler, E as EventMap, l as EventTypes, O as OpaqueTransportMessage, h as OpaqueTransportMessageSchema, n as ProtocolError, o as ProtocolErrorType, d as ServerTransporOptions, S as ServerTransport, e as Session, T as Transport, b as TransportClientId, i as TransportMessage, g as TransportMessageSchema, f as TransportStatus, k as isStreamClose, j as isStreamOpen } from '../index-bbccacef.js';
1
+ export { a as ClientTransport, c as ClientTransportOptions, C as Connection, m as EventHandler, E as EventMap, l as EventTypes, O as OpaqueTransportMessage, h as OpaqueTransportMessageSchema, n as ProtocolError, o as ProtocolErrorType, S as ServerTransport, e as Session, T as Transport, b as TransportClientId, i as TransportMessage, g as TransportMessageSchema, d as TransportOptions, f as TransportStatus, k as isStreamClose, j as isStreamOpen } from '../index-2e402bb8.js';
2
2
  import '../types-3e5768ec.js';
3
3
  import '@sinclair/typebox';
@@ -6,7 +6,7 @@ import {
6
6
  ServerTransport,
7
7
  Session,
8
8
  Transport
9
- } from "../chunk-B7VTDQR7.js";
9
+ } from "../chunk-5TYDJKOP.js";
10
10
  import {
11
11
  OpaqueTransportMessageSchema,
12
12
  TransportMessageSchema
@@ -2,8 +2,8 @@ import * as it_pushable from 'it-pushable';
2
2
  import { C as Codec } from '../types-3e5768ec.js';
3
3
  import WebSocket from 'isomorphic-ws';
4
4
  import http from 'node:http';
5
- import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-bbccacef.js';
6
- import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-ebd945c0.js';
5
+ import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-2e402bb8.js';
6
+ import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-4d392f6c.js';
7
7
  import { Static } from '@sinclair/typebox';
8
8
  import net from 'node:net';
9
9
 
@@ -2,8 +2,8 @@ import * as it_pushable from 'it-pushable';
2
2
  import { C as Codec } from '../types-3e5768ec.js';
3
3
  import WebSocket from 'isomorphic-ws';
4
4
  import http from 'node:http';
5
- import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-bbccacef.js';
6
- import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-ebd945c0.js';
5
+ import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-2e402bb8.js';
6
+ import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-4d392f6c.js';
7
7
  import { Static } from '@sinclair/typebox';
8
8
  import net from 'node:net';
9
9
 
@@ -5,7 +5,7 @@ import {
5
5
  import "../chunk-RPIDSIQG.js";
6
6
  import {
7
7
  Session
8
- } from "../chunk-B7VTDQR7.js";
8
+ } from "../chunk-5TYDJKOP.js";
9
9
  import {
10
10
  coerceErrorString
11
11
  } from "../chunk-GFRAOY75.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@replit/river",
3
3
  "description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
4
- "version": "0.15.2",
4
+ "version": "0.15.4",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {