@replit/river 0.15.1 → 0.15.2

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 (35) hide show
  1. package/README.md +41 -22
  2. package/dist/{builder-660d3140.d.ts → builder-ebd945c0.d.ts} +1 -1
  3. package/dist/{chunk-O6YQ3JAH.js → chunk-B7VTDQR7.js} +147 -37
  4. package/dist/{chunk-MNWOTQWX.js → chunk-UJHTHOTT.js} +1 -1
  5. package/dist/{chunk-5TX4BKAD.js → chunk-ZRB6IKPV.js} +1 -1
  6. package/dist/{connection-162c0f7b.d.ts → connection-10a24478.d.ts} +1 -1
  7. package/dist/{connection-93daccc3.d.ts → connection-f4492948.d.ts} +1 -1
  8. package/dist/{index-76b801f8.d.ts → index-bbccacef.d.ts} +84 -11
  9. package/dist/router/index.d.cts +3 -3
  10. package/dist/router/index.d.ts +3 -3
  11. package/dist/transport/impls/uds/client.cjs +197 -88
  12. package/dist/transport/impls/uds/client.d.cts +3 -3
  13. package/dist/transport/impls/uds/client.d.ts +3 -3
  14. package/dist/transport/impls/uds/client.js +2 -2
  15. package/dist/transport/impls/uds/server.cjs +66 -69
  16. package/dist/transport/impls/uds/server.d.cts +3 -3
  17. package/dist/transport/impls/uds/server.d.ts +3 -3
  18. package/dist/transport/impls/uds/server.js +2 -2
  19. package/dist/transport/impls/ws/client.cjs +197 -90
  20. package/dist/transport/impls/ws/client.d.cts +3 -3
  21. package/dist/transport/impls/ws/client.d.ts +3 -3
  22. package/dist/transport/impls/ws/client.js +2 -2
  23. package/dist/transport/impls/ws/server.cjs +66 -69
  24. package/dist/transport/impls/ws/server.d.cts +3 -3
  25. package/dist/transport/impls/ws/server.d.ts +3 -3
  26. package/dist/transport/impls/ws/server.js +2 -2
  27. package/dist/transport/index.cjs +197 -90
  28. package/dist/transport/index.d.cts +1 -1
  29. package/dist/transport/index.d.ts +1 -1
  30. package/dist/transport/index.js +1 -1
  31. package/dist/util/testHelpers.cjs +61 -64
  32. package/dist/util/testHelpers.d.cts +10 -4
  33. package/dist/util/testHelpers.d.ts +10 -4
  34. package/dist/util/testHelpers.js +13 -5
  35. package/package.json +1 -1
@@ -134,60 +134,6 @@ var EventDispatcher = class {
134
134
 
135
135
  // transport/session.ts
136
136
  var import_nanoid2 = require("nanoid");
137
-
138
- // codec/json.ts
139
- var encoder = new TextEncoder();
140
- var decoder = new TextDecoder();
141
- function uint8ArrayToBase64(uint8Array) {
142
- let binary = "";
143
- uint8Array.forEach((byte) => {
144
- binary += String.fromCharCode(byte);
145
- });
146
- return btoa(binary);
147
- }
148
- function base64ToUint8Array(base64) {
149
- const binaryString = atob(base64);
150
- const uint8Array = new Uint8Array(binaryString.length);
151
- for (let i = 0; i < binaryString.length; i++) {
152
- uint8Array[i] = binaryString.charCodeAt(i);
153
- }
154
- return uint8Array;
155
- }
156
- var NaiveJsonCodec = {
157
- toBuffer: (obj) => {
158
- return encoder.encode(
159
- JSON.stringify(obj, function replacer(key) {
160
- const val = this[key];
161
- if (val instanceof Uint8Array) {
162
- return { $t: uint8ArrayToBase64(val) };
163
- } else {
164
- return val;
165
- }
166
- })
167
- );
168
- },
169
- fromBuffer: (buff) => {
170
- try {
171
- const parsed = JSON.parse(
172
- decoder.decode(buff),
173
- function reviver(_key, val) {
174
- if (val?.$t) {
175
- return base64ToUint8Array(val.$t);
176
- } else {
177
- return val;
178
- }
179
- }
180
- );
181
- if (typeof parsed === "object")
182
- return parsed;
183
- return null;
184
- } catch {
185
- return null;
186
- }
187
- }
188
- };
189
-
190
- // transport/session.ts
191
137
  var nanoid2 = (0, import_nanoid2.customAlphabet)("1234567890abcdefghijklmnopqrstuvxyz", 6);
192
138
  var unsafeId = () => nanoid2();
193
139
  var Connection = class {
@@ -196,15 +142,6 @@ var Connection = class {
196
142
  this.debugId = `conn-${unsafeId()}`;
197
143
  }
198
144
  };
199
- var HEARTBEAT_INTERVAL_MS = 1e3;
200
- var HEARTBEATS_TILL_DEAD = 2;
201
- var SESSION_DISCONNECT_GRACE_MS = 5e3;
202
- var defaultSessionOptions = {
203
- heartbeatIntervalMs: HEARTBEAT_INTERVAL_MS,
204
- heartbeatsUntilDead: HEARTBEATS_TILL_DEAD,
205
- sessionDisconnectGraceMs: SESSION_DISCONNECT_GRACE_MS,
206
- codec: NaiveJsonCodec
207
- };
208
145
  var Session = class {
209
146
  codec;
210
147
  options;
@@ -399,14 +336,146 @@ function coerceErrorString(err) {
399
336
  return `[coerced to error] ${String(err)}`;
400
337
  }
401
338
 
339
+ // transport/rateLimit.ts
340
+ var LeakyBucketRateLimit = class {
341
+ budgetConsumed;
342
+ intervalHandles;
343
+ options;
344
+ constructor(options) {
345
+ this.options = options;
346
+ this.budgetConsumed = /* @__PURE__ */ new Map();
347
+ this.intervalHandles = /* @__PURE__ */ new Map();
348
+ }
349
+ getBackoffMs(user) {
350
+ if (!this.budgetConsumed.has(user))
351
+ return 0;
352
+ const exponent = Math.max(0, this.getBudgetConsumed(user) - 1);
353
+ const jitter = Math.floor(Math.random() * this.options.maxJitterMs);
354
+ const backoffMs = Math.min(
355
+ this.options.baseIntervalMs * 2 ** exponent,
356
+ this.options.maxBackoffMs
357
+ );
358
+ return backoffMs + jitter;
359
+ }
360
+ get totalBudgetRestoreTime() {
361
+ return this.options.budgetRestoreIntervalMs * this.options.attemptBudgetCapacity;
362
+ }
363
+ consumeBudget(user) {
364
+ this.stopLeak(user);
365
+ this.budgetConsumed.set(user, this.getBudgetConsumed(user) + 1);
366
+ }
367
+ getBudgetConsumed(user) {
368
+ return this.budgetConsumed.get(user) ?? 0;
369
+ }
370
+ hasBudget(user) {
371
+ return this.getBudgetConsumed(user) < this.options.attemptBudgetCapacity;
372
+ }
373
+ startRestoringBudget(user) {
374
+ if (this.intervalHandles.has(user)) {
375
+ return;
376
+ }
377
+ const restoreBudgetForUser = () => {
378
+ const currentBudget = this.budgetConsumed.get(user);
379
+ if (!currentBudget) {
380
+ this.stopLeak(user);
381
+ return;
382
+ }
383
+ const newBudget = currentBudget - 1;
384
+ if (newBudget === 0) {
385
+ this.budgetConsumed.delete(user);
386
+ return;
387
+ }
388
+ this.budgetConsumed.set(user, newBudget);
389
+ };
390
+ restoreBudgetForUser();
391
+ const intervalHandle = setInterval(
392
+ restoreBudgetForUser,
393
+ this.options.budgetRestoreIntervalMs
394
+ );
395
+ this.intervalHandles.set(user, intervalHandle);
396
+ }
397
+ stopLeak(user) {
398
+ if (!this.intervalHandles.has(user)) {
399
+ return;
400
+ }
401
+ clearInterval(this.intervalHandles.get(user));
402
+ this.intervalHandles.delete(user);
403
+ }
404
+ close() {
405
+ for (const user of this.intervalHandles.keys()) {
406
+ this.stopLeak(user);
407
+ }
408
+ }
409
+ };
410
+
411
+ // codec/json.ts
412
+ var encoder = new TextEncoder();
413
+ var decoder = new TextDecoder();
414
+ function uint8ArrayToBase64(uint8Array) {
415
+ let binary = "";
416
+ uint8Array.forEach((byte) => {
417
+ binary += String.fromCharCode(byte);
418
+ });
419
+ return btoa(binary);
420
+ }
421
+ function base64ToUint8Array(base64) {
422
+ const binaryString = atob(base64);
423
+ const uint8Array = new Uint8Array(binaryString.length);
424
+ for (let i = 0; i < binaryString.length; i++) {
425
+ uint8Array[i] = binaryString.charCodeAt(i);
426
+ }
427
+ return uint8Array;
428
+ }
429
+ var NaiveJsonCodec = {
430
+ toBuffer: (obj) => {
431
+ return encoder.encode(
432
+ JSON.stringify(obj, function replacer(key) {
433
+ const val = this[key];
434
+ if (val instanceof Uint8Array) {
435
+ return { $t: uint8ArrayToBase64(val) };
436
+ } else {
437
+ return val;
438
+ }
439
+ })
440
+ );
441
+ },
442
+ fromBuffer: (buff) => {
443
+ try {
444
+ const parsed = JSON.parse(
445
+ decoder.decode(buff),
446
+ function reviver(_key, val) {
447
+ if (val?.$t) {
448
+ return base64ToUint8Array(val.$t);
449
+ } else {
450
+ return val;
451
+ }
452
+ }
453
+ );
454
+ if (typeof parsed === "object")
455
+ return parsed;
456
+ return null;
457
+ } catch {
458
+ return null;
459
+ }
460
+ }
461
+ };
462
+
402
463
  // transport/transport.ts
403
- var RECONNECT_JITTER_MAX_MS = 500;
404
- var RECONNECT_INTERVAL_MS = 250;
405
464
  var defaultTransportOptions = {
406
- retryIntervalMs: RECONNECT_INTERVAL_MS,
407
- retryJitterMs: RECONNECT_JITTER_MAX_MS,
408
- retryAttemptsMax: 5,
409
- ...defaultSessionOptions
465
+ heartbeatIntervalMs: 1e3,
466
+ heartbeatsUntilDead: 2,
467
+ sessionDisconnectGraceMs: 5e3,
468
+ codec: NaiveJsonCodec
469
+ };
470
+ var defaultClientTransportOptions = {
471
+ connectionRetryOptions: {
472
+ baseIntervalMs: 250,
473
+ maxJitterMs: 200,
474
+ maxBackoffMs: 32e3,
475
+ attemptBudgetCapacity: 15,
476
+ budgetRestoreIntervalMs: 200
477
+ },
478
+ ...defaultTransportOptions
410
479
  };
411
480
  var Transport = class {
412
481
  /**
@@ -681,14 +750,26 @@ var Transport = class {
681
750
  }
682
751
  };
683
752
  var ClientTransport = class extends Transport {
753
+ /**
754
+ * The options for this transport.
755
+ */
756
+ options;
684
757
  /**
685
758
  * The map of reconnect promises for each client ID.
686
759
  */
687
760
  inflightConnectionPromises;
761
+ retryBudget;
688
762
  tryReconnecting = true;
689
763
  constructor(clientId, providedOptions) {
690
764
  super(clientId, providedOptions);
765
+ this.options = {
766
+ ...defaultClientTransportOptions,
767
+ ...providedOptions
768
+ };
691
769
  this.inflightConnectionPromises = /* @__PURE__ */ new Map();
770
+ this.retryBudget = new LeakyBucketRateLimit(
771
+ this.options.connectionRetryOptions
772
+ );
692
773
  }
693
774
  handleConnection(conn, to) {
694
775
  if (this.state !== "open")
@@ -719,7 +800,10 @@ var ClientTransport = class extends Transport {
719
800
  log?.info(
720
801
  `${this.clientId} -- connection (id: ${conn.debugId}) to ${to} disconnected`
721
802
  );
722
- void this.connect(to);
803
+ this.inflightConnectionPromises.delete(to);
804
+ if (this.tryReconnecting) {
805
+ void this.connect(to);
806
+ }
723
807
  });
724
808
  conn.addErrorListener((err) => {
725
809
  log?.warn(
@@ -770,41 +854,64 @@ var ClientTransport = class extends Transport {
770
854
  * Manually attempts to connect to a client.
771
855
  * @param to The client ID of the node to connect to.
772
856
  */
773
- async connect(to, attempt = 0) {
774
- if (this.state !== "open" || !this.tryReconnecting) {
857
+ async connect(to) {
858
+ const canProceedWithConnection = () => this.state === "open";
859
+ if (!canProceedWithConnection()) {
775
860
  log?.info(
776
- `${this.clientId} -- transport state is no longer open, not attempting connection`
861
+ `${this.clientId} -- transport state is no longer open, cancelling attempt to connect to ${to}`
777
862
  );
778
863
  return;
779
864
  }
780
865
  let reconnectPromise = this.inflightConnectionPromises.get(to);
781
866
  if (!reconnectPromise) {
782
- reconnectPromise = this.createNewOutgoingConnection(to).then((conn) => {
867
+ log?.info(`${this.clientId} -- attempting connection to ${to}`);
868
+ const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
869
+ 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
+ log?.warn(`${this.clientId} -- ${errMsg}`);
872
+ this.protocolError(ProtocolError.RetriesExceeded, errMsg);
873
+ return;
874
+ }
875
+ let sleep = Promise.resolve();
876
+ const backoffMs = this.retryBudget.getBackoffMs(to);
877
+ if (backoffMs > 0) {
878
+ sleep = new Promise((resolve) => setTimeout(resolve, backoffMs));
879
+ }
880
+ this.retryBudget.consumeBudget(to);
881
+ reconnectPromise = sleep.then(() => {
882
+ if (!canProceedWithConnection()) {
883
+ throw new Error("transport state is no longer open");
884
+ }
885
+ }).then(() => this.createNewOutgoingConnection(to)).then((conn) => {
886
+ if (!canProceedWithConnection()) {
887
+ log?.info(
888
+ `${this.clientId} -- transport state is no longer open, closing pre-handshake connection (id: ${conn.debugId}) to ${to}`
889
+ );
890
+ conn.close();
891
+ throw new Error("transport state is no longer open");
892
+ }
893
+ this.retryBudget.startRestoringBudget(to);
783
894
  this.sendHandshake(to, conn);
784
895
  return conn;
785
896
  });
786
897
  this.inflightConnectionPromises.set(to, reconnectPromise);
898
+ } else {
899
+ log?.info(
900
+ `${this.clientId} -- attempting connection to ${to} (reusing previous attempt)`
901
+ );
787
902
  }
788
903
  try {
789
904
  await reconnectPromise;
790
905
  } catch (error) {
791
- const errStr = coerceErrorString(error);
792
906
  this.inflightConnectionPromises.delete(to);
793
- const shouldRetry = this.state === "open" && this.tryReconnecting;
794
- if (!shouldRetry)
795
- return;
796
- if (attempt >= this.options.retryAttemptsMax) {
797
- const errMsg = `connection to ${to} failed after ${attempt} attempts (${errStr}), giving up`;
798
- log?.error(`${this.clientId} -- ${errMsg}`);
799
- this.protocolError(ProtocolError.RetriesExceeded, errMsg);
800
- return;
907
+ const errStr = coerceErrorString(error);
908
+ if (!this.tryReconnecting || !canProceedWithConnection()) {
909
+ log?.warn(`${this.clientId} -- connection to ${to} failed (${errStr})`);
801
910
  } else {
802
- const jitter = Math.floor(Math.random() * this.options.retryJitterMs);
803
- const backoffMs = this.options.retryIntervalMs * 2 ** attempt + jitter;
804
911
  log?.warn(
805
- `${this.clientId} -- connection to ${to} failed (${errStr}), trying again in ${backoffMs}ms`
912
+ `${this.clientId} -- connection to ${to} failed (${errStr}), retrying`
806
913
  );
807
- setTimeout(() => void this.connect(to, attempt + 1), backoffMs);
914
+ return this.connect(to);
808
915
  }
809
916
  }
810
917
  }
@@ -817,9 +924,9 @@ var ClientTransport = class extends Transport {
817
924
  log?.debug(`${this.clientId} -- sending handshake request to ${to}`);
818
925
  conn.send(this.codec.toBuffer(requestMsg));
819
926
  }
820
- onDisconnect(conn, session) {
821
- this.inflightConnectionPromises.delete(session.to);
822
- super.onDisconnect(conn, session);
927
+ close() {
928
+ this.retryBudget.close();
929
+ super.close();
823
930
  }
824
931
  };
825
932
 
@@ -1,6 +1,6 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-76b801f8.js';
3
- import { W as WebSocketConnection } from '../../../connection-93daccc3.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-bbccacef.js';
3
+ import { W as WebSocketConnection } from '../../../connection-f4492948.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
 
@@ -21,7 +21,7 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
21
21
  * @param serverId The ID of the server this transport is connecting to.
22
22
  * @param providedOptions An optional object containing configuration options for the transport.
23
23
  */
24
- constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
24
+ constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: ProvidedClientTransportOptions);
25
25
  createNewOutgoingConnection(to: string): Promise<WebSocketConnection>;
26
26
  }
27
27
 
@@ -1,6 +1,6 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-76b801f8.js';
3
- import { W as WebSocketConnection } from '../../../connection-93daccc3.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as ProvidedClientTransportOptions } from '../../../index-bbccacef.js';
3
+ import { W as WebSocketConnection } from '../../../connection-f4492948.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
 
@@ -21,7 +21,7 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
21
21
  * @param serverId The ID of the server this transport is connecting to.
22
22
  * @param providedOptions An optional object containing configuration options for the transport.
23
23
  */
24
- constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
24
+ constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: ProvidedClientTransportOptions);
25
25
  createNewOutgoingConnection(to: string): Promise<WebSocketConnection>;
26
26
  }
27
27
 
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  WebSocketConnection
3
- } from "../../../chunk-5TX4BKAD.js";
3
+ } from "../../../chunk-ZRB6IKPV.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-O6YQ3JAH.js";
6
+ } from "../../../chunk-B7VTDQR7.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import {
9
9
  log
@@ -142,60 +142,6 @@ var EventDispatcher = class {
142
142
 
143
143
  // transport/session.ts
144
144
  var import_nanoid2 = require("nanoid");
145
-
146
- // codec/json.ts
147
- var encoder = new TextEncoder();
148
- var decoder = new TextDecoder();
149
- function uint8ArrayToBase64(uint8Array) {
150
- let binary = "";
151
- uint8Array.forEach((byte) => {
152
- binary += String.fromCharCode(byte);
153
- });
154
- return btoa(binary);
155
- }
156
- function base64ToUint8Array(base64) {
157
- const binaryString = atob(base64);
158
- const uint8Array = new Uint8Array(binaryString.length);
159
- for (let i = 0; i < binaryString.length; i++) {
160
- uint8Array[i] = binaryString.charCodeAt(i);
161
- }
162
- return uint8Array;
163
- }
164
- var NaiveJsonCodec = {
165
- toBuffer: (obj) => {
166
- return encoder.encode(
167
- JSON.stringify(obj, function replacer(key) {
168
- const val = this[key];
169
- if (val instanceof Uint8Array) {
170
- return { $t: uint8ArrayToBase64(val) };
171
- } else {
172
- return val;
173
- }
174
- })
175
- );
176
- },
177
- fromBuffer: (buff) => {
178
- try {
179
- const parsed = JSON.parse(
180
- decoder.decode(buff),
181
- function reviver(_key, val) {
182
- if (val?.$t) {
183
- return base64ToUint8Array(val.$t);
184
- } else {
185
- return val;
186
- }
187
- }
188
- );
189
- if (typeof parsed === "object")
190
- return parsed;
191
- return null;
192
- } catch {
193
- return null;
194
- }
195
- }
196
- };
197
-
198
- // transport/session.ts
199
145
  var nanoid2 = (0, import_nanoid2.customAlphabet)("1234567890abcdefghijklmnopqrstuvxyz", 6);
200
146
  var unsafeId = () => nanoid2();
201
147
  var Connection = class {
@@ -204,15 +150,6 @@ var Connection = class {
204
150
  this.debugId = `conn-${unsafeId()}`;
205
151
  }
206
152
  };
207
- var HEARTBEAT_INTERVAL_MS = 1e3;
208
- var HEARTBEATS_TILL_DEAD = 2;
209
- var SESSION_DISCONNECT_GRACE_MS = 5e3;
210
- var defaultSessionOptions = {
211
- heartbeatIntervalMs: HEARTBEAT_INTERVAL_MS,
212
- heartbeatsUntilDead: HEARTBEATS_TILL_DEAD,
213
- sessionDisconnectGraceMs: SESSION_DISCONNECT_GRACE_MS,
214
- codec: NaiveJsonCodec
215
- };
216
153
  var Session = class {
217
154
  codec;
218
155
  options;
@@ -407,14 +344,74 @@ function coerceErrorString(err) {
407
344
  return `[coerced to error] ${String(err)}`;
408
345
  }
409
346
 
347
+ // codec/json.ts
348
+ var encoder = new TextEncoder();
349
+ var decoder = new TextDecoder();
350
+ function uint8ArrayToBase64(uint8Array) {
351
+ let binary = "";
352
+ uint8Array.forEach((byte) => {
353
+ binary += String.fromCharCode(byte);
354
+ });
355
+ return btoa(binary);
356
+ }
357
+ function base64ToUint8Array(base64) {
358
+ const binaryString = atob(base64);
359
+ const uint8Array = new Uint8Array(binaryString.length);
360
+ for (let i = 0; i < binaryString.length; i++) {
361
+ uint8Array[i] = binaryString.charCodeAt(i);
362
+ }
363
+ return uint8Array;
364
+ }
365
+ var NaiveJsonCodec = {
366
+ toBuffer: (obj) => {
367
+ return encoder.encode(
368
+ JSON.stringify(obj, function replacer(key) {
369
+ const val = this[key];
370
+ if (val instanceof Uint8Array) {
371
+ return { $t: uint8ArrayToBase64(val) };
372
+ } else {
373
+ return val;
374
+ }
375
+ })
376
+ );
377
+ },
378
+ fromBuffer: (buff) => {
379
+ try {
380
+ const parsed = JSON.parse(
381
+ decoder.decode(buff),
382
+ function reviver(_key, val) {
383
+ if (val?.$t) {
384
+ return base64ToUint8Array(val.$t);
385
+ } else {
386
+ return val;
387
+ }
388
+ }
389
+ );
390
+ if (typeof parsed === "object")
391
+ return parsed;
392
+ return null;
393
+ } catch {
394
+ return null;
395
+ }
396
+ }
397
+ };
398
+
410
399
  // transport/transport.ts
411
- var RECONNECT_JITTER_MAX_MS = 500;
412
- var RECONNECT_INTERVAL_MS = 250;
413
400
  var defaultTransportOptions = {
414
- retryIntervalMs: RECONNECT_INTERVAL_MS,
415
- retryJitterMs: RECONNECT_JITTER_MAX_MS,
416
- retryAttemptsMax: 5,
417
- ...defaultSessionOptions
401
+ heartbeatIntervalMs: 1e3,
402
+ heartbeatsUntilDead: 2,
403
+ sessionDisconnectGraceMs: 5e3,
404
+ codec: NaiveJsonCodec
405
+ };
406
+ var defaultClientTransportOptions = {
407
+ connectionRetryOptions: {
408
+ baseIntervalMs: 250,
409
+ maxJitterMs: 200,
410
+ maxBackoffMs: 32e3,
411
+ attemptBudgetCapacity: 15,
412
+ budgetRestoreIntervalMs: 200
413
+ },
414
+ ...defaultTransportOptions
418
415
  };
419
416
  var Transport = class {
420
417
  /**
@@ -1,13 +1,13 @@
1
- import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-76b801f8.js';
1
+ import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-bbccacef.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-93daccc3.js';
4
+ import { W as WebSocketConnection } from '../../../connection-f4492948.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<TransportOptions>);
10
+ constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: Partial<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, c as TransportOptions } from '../../../index-76b801f8.js';
1
+ import { S as ServerTransport, b as TransportClientId, d as ProvidedTransportOptions } from '../../../index-bbccacef.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-93daccc3.js';
4
+ import { W as WebSocketConnection } from '../../../connection-f4492948.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<TransportOptions>);
10
+ constructor(wss: WebSocketServer, clientId: TransportClientId, providedOptions?: Partial<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-5TX4BKAD.js";
3
+ } from "../../../chunk-ZRB6IKPV.js";
4
4
  import {
5
5
  ServerTransport
6
- } from "../../../chunk-O6YQ3JAH.js";
6
+ } from "../../../chunk-B7VTDQR7.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import "../../../chunk-H4BYJELI.js";
9
9
  import "../../../chunk-GZ7HCLLM.js";