@replit/river 0.23.10 → 0.23.11

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 (52) hide show
  1. package/dist/{chunk-KBAZ5TWE.js → chunk-EOJMKMDO.js} +32 -40
  2. package/dist/chunk-EOJMKMDO.js.map +1 -0
  3. package/dist/{chunk-Z4G27Y2I.js → chunk-HM7VDTDJ.js} +2 -2
  4. package/dist/{chunk-FRICSBDW.js → chunk-MEHCOYKJ.js} +2 -2
  5. package/dist/{chunk-FRICSBDW.js.map → chunk-MEHCOYKJ.js.map} +1 -1
  6. package/dist/{chunk-UXQMGZKP.js → chunk-T6YEMFUF.js} +2 -2
  7. package/dist/{chunk-B323CECK.js → chunk-ZSKCZYVU.js} +9 -9
  8. package/dist/chunk-ZSKCZYVU.js.map +1 -0
  9. package/dist/{connection-700340c4.d.ts → connection-261eee8f.d.ts} +1 -1
  10. package/dist/{connection-efcd4e1a.d.ts → connection-c1eeb95d.d.ts} +1 -1
  11. package/dist/router/index.cjs +8 -8
  12. package/dist/router/index.cjs.map +1 -1
  13. package/dist/router/index.d.cts +11 -7
  14. package/dist/router/index.d.ts +11 -7
  15. package/dist/router/index.js +2 -2
  16. package/dist/{services-409c5545.d.ts → services-524bab79.d.ts} +1 -1
  17. package/dist/transport/impls/uds/client.cjs +30 -38
  18. package/dist/transport/impls/uds/client.cjs.map +1 -1
  19. package/dist/transport/impls/uds/client.d.cts +2 -2
  20. package/dist/transport/impls/uds/client.d.ts +2 -2
  21. package/dist/transport/impls/uds/client.js +3 -3
  22. package/dist/transport/impls/uds/server.cjs +10 -29
  23. package/dist/transport/impls/uds/server.cjs.map +1 -1
  24. package/dist/transport/impls/uds/server.d.cts +2 -2
  25. package/dist/transport/impls/uds/server.d.ts +2 -2
  26. package/dist/transport/impls/uds/server.js +3 -3
  27. package/dist/transport/impls/ws/client.cjs +30 -38
  28. package/dist/transport/impls/ws/client.cjs.map +1 -1
  29. package/dist/transport/impls/ws/client.d.cts +2 -2
  30. package/dist/transport/impls/ws/client.d.ts +2 -2
  31. package/dist/transport/impls/ws/client.js +3 -3
  32. package/dist/transport/impls/ws/server.cjs +10 -29
  33. package/dist/transport/impls/ws/server.cjs.map +1 -1
  34. package/dist/transport/impls/ws/server.d.cts +2 -2
  35. package/dist/transport/impls/ws/server.d.ts +2 -2
  36. package/dist/transport/impls/ws/server.js +3 -3
  37. package/dist/transport/index.cjs +31 -39
  38. package/dist/transport/index.cjs.map +1 -1
  39. package/dist/transport/index.d.cts +1 -1
  40. package/dist/transport/index.d.ts +1 -1
  41. package/dist/transport/index.js +2 -2
  42. package/dist/{transport-cf856c41.d.ts → transport-c8f36f6d.d.ts} +2 -4
  43. package/dist/util/testHelpers.cjs +4 -21
  44. package/dist/util/testHelpers.cjs.map +1 -1
  45. package/dist/util/testHelpers.d.cts +2 -2
  46. package/dist/util/testHelpers.d.ts +2 -2
  47. package/dist/util/testHelpers.js +3 -3
  48. package/package.json +1 -1
  49. package/dist/chunk-B323CECK.js.map +0 -1
  50. package/dist/chunk-KBAZ5TWE.js.map +0 -1
  51. /package/dist/{chunk-Z4G27Y2I.js.map → chunk-HM7VDTDJ.js.map} +0 -0
  52. /package/dist/{chunk-UXQMGZKP.js.map → chunk-T6YEMFUF.js.map} +0 -0
@@ -1,8 +1,8 @@
1
- import { S as SerializedServerSchema, A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-409c5545.js';
2
- export { C as Client, E as Err, O as Ok, z as Output, k as ProcErrors, g as ProcHandler, h as ProcInit, i as ProcInput, j as ProcOutput, l 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, n as SerializedServiceSchema, e as Service, f as ServiceConfiguration, m 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-409c5545.js';
1
+ import { S as SerializedServerSchema, A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-524bab79.js';
2
+ export { C as Client, E as Err, O as Ok, z as Output, k as ProcErrors, g as ProcHandler, h as ProcInit, i as ProcInput, j as ProcOutput, l 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, n as SerializedServiceSchema, e as Service, f as ServiceConfiguration, m 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-524bab79.js';
3
3
  import { Static } from '@sinclair/typebox';
4
- import { d as ServerTransport, C as Connection, f as ServerHandshakeOptions, b as ServiceContext } from '../transport-cf856c41.js';
5
- export { g as ParsedMetadata, h as ServiceContextWithState, i as ServiceContextWithTransportInfo, j as createClientHandshakeOptions, k as createServerHandshakeOptions } from '../transport-cf856c41.js';
4
+ import { d as ServerTransport, C as Connection, f as ServerHandshakeOptions, b as ServiceContext } from '../transport-c8f36f6d.js';
5
+ export { g as ParsedMetadata, h as ServiceContextWithState, i as ServiceContextWithTransportInfo, j as createClientHandshakeOptions, k as createServerHandshakeOptions } from '../transport-c8f36f6d.js';
6
6
  import { Pushable } from 'it-pushable';
7
7
  import '../index-60f03cb7.js';
8
8
  import '@sinclair/typebox/value';
@@ -42,7 +42,11 @@ type PayloadBreakage = {
42
42
  reason: 'field-breakage';
43
43
  fieldBreakages: Record<string, PayloadBreakage>;
44
44
  };
45
- declare function diffServerSchema(oldServer: SerializedServerSchema, newServer: SerializedServerSchema): ServerBreakage | null;
45
+ interface DiffOptions {
46
+ allowServiceRemoval?: boolean;
47
+ allowProcedureRemoval?: boolean;
48
+ }
49
+ declare function diffServerSchema(oldServer: SerializedServerSchema, newServer: SerializedServerSchema, options?: DiffOptions): ServerBreakage | null;
46
50
 
47
51
  /**
48
52
  * Represents a server with a set of services. Use {@link createServer} to create it.
@@ -77,6 +81,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
77
81
  extendedContext?: Omit<ServiceContext, 'state'>;
78
82
  }>): Server<Services>;
79
83
 
80
- var version = "0.23.10";
84
+ var version = "0.23.11";
81
85
 
82
- export { PayloadBreakage, PayloadType, ProcedureBreakage, version as RIVER_VERSION, Result, RiverError, SerializedServerSchema, Server, ServerBreakage, ServiceBreakage, ServiceContext, createServer, diffServerSchema };
86
+ export { DiffOptions, PayloadBreakage, PayloadType, ProcedureBreakage, version as RIVER_VERSION, Result, RiverError, SerializedServerSchema, Server, ServerBreakage, ServiceBreakage, ServiceContext, createServer, diffServerSchema };
@@ -1,8 +1,8 @@
1
- import { S as SerializedServerSchema, A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-409c5545.js';
2
- export { C as Client, E as Err, O as Ok, z as Output, k as ProcErrors, g as ProcHandler, h as ProcInit, i as ProcInput, j as ProcOutput, l 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, n as SerializedServiceSchema, e as Service, f as ServiceConfiguration, m 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-409c5545.js';
1
+ import { S as SerializedServerSchema, A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-524bab79.js';
2
+ export { C as Client, E as Err, O as Ok, z as Output, k as ProcErrors, g as ProcHandler, h as ProcInit, i as ProcInput, j as ProcOutput, l 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, n as SerializedServiceSchema, e as Service, f as ServiceConfiguration, m 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-524bab79.js';
3
3
  import { Static } from '@sinclair/typebox';
4
- import { d as ServerTransport, C as Connection, f as ServerHandshakeOptions, b as ServiceContext } from '../transport-cf856c41.js';
5
- export { g as ParsedMetadata, h as ServiceContextWithState, i as ServiceContextWithTransportInfo, j as createClientHandshakeOptions, k as createServerHandshakeOptions } from '../transport-cf856c41.js';
4
+ import { d as ServerTransport, C as Connection, f as ServerHandshakeOptions, b as ServiceContext } from '../transport-c8f36f6d.js';
5
+ export { g as ParsedMetadata, h as ServiceContextWithState, i as ServiceContextWithTransportInfo, j as createClientHandshakeOptions, k as createServerHandshakeOptions } from '../transport-c8f36f6d.js';
6
6
  import { Pushable } from 'it-pushable';
7
7
  import '../index-60f03cb7.js';
8
8
  import '@sinclair/typebox/value';
@@ -42,7 +42,11 @@ type PayloadBreakage = {
42
42
  reason: 'field-breakage';
43
43
  fieldBreakages: Record<string, PayloadBreakage>;
44
44
  };
45
- declare function diffServerSchema(oldServer: SerializedServerSchema, newServer: SerializedServerSchema): ServerBreakage | null;
45
+ interface DiffOptions {
46
+ allowServiceRemoval?: boolean;
47
+ allowProcedureRemoval?: boolean;
48
+ }
49
+ declare function diffServerSchema(oldServer: SerializedServerSchema, newServer: SerializedServerSchema, options?: DiffOptions): ServerBreakage | null;
46
50
 
47
51
  /**
48
52
  * Represents a server with a set of services. Use {@link createServer} to create it.
@@ -77,6 +81,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
77
81
  extendedContext?: Omit<ServiceContext, 'state'>;
78
82
  }>): Server<Services>;
79
83
 
80
- var version = "0.23.10";
84
+ var version = "0.23.11";
81
85
 
82
- export { PayloadBreakage, PayloadType, ProcedureBreakage, version as RIVER_VERSION, Result, RiverError, SerializedServerSchema, Server, ServerBreakage, ServiceBreakage, ServiceContext, createServer, diffServerSchema };
86
+ export { DiffOptions, PayloadBreakage, PayloadType, ProcedureBreakage, version as RIVER_VERSION, Result, RiverError, SerializedServerSchema, Server, ServerBreakage, ServiceBreakage, ServiceContext, createServer, diffServerSchema };
@@ -11,10 +11,10 @@ import {
11
11
  createServerHandshakeOptions,
12
12
  diffServerSchema,
13
13
  serializeSchema
14
- } from "../chunk-B323CECK.js";
14
+ } from "../chunk-ZSKCZYVU.js";
15
15
  import {
16
16
  version
17
- } from "../chunk-FRICSBDW.js";
17
+ } from "../chunk-MEHCOYKJ.js";
18
18
  export {
19
19
  Err,
20
20
  Ok,
@@ -1,5 +1,5 @@
1
1
  import { Static, TObject, TUnion, TString, TSchema, TNever, TLiteral } from '@sinclair/typebox';
2
- import { c as ClientTransport, C as Connection, l as ClientHandshakeOptions, i as ServiceContextWithTransportInfo } from './transport-cf856c41.js';
2
+ import { c as ClientTransport, C as Connection, l as ClientHandshakeOptions, i as ServiceContextWithTransportInfo } from './transport-c8f36f6d.js';
3
3
  import { Pushable } from 'it-pushable';
4
4
  import { T as TransportClientId } from './index-60f03cb7.js';
5
5
 
@@ -110,7 +110,7 @@ function isAck(controlFlag) {
110
110
  var import_api = require("@opentelemetry/api");
111
111
 
112
112
  // package.json
113
- var version = "0.23.10";
113
+ var version = "0.23.11";
114
114
 
115
115
  // tracing/index.ts
116
116
  function getPropagationContext(ctx) {
@@ -384,19 +384,8 @@ var Session = class {
384
384
  `starting ${this.options.sessionDisconnectGraceMs}ms grace period until session to ${this.to} is closed`,
385
385
  this.loggingMetadata
386
386
  );
387
- this.cancelGrace({ keepHeartbeatMisses: true });
387
+ this.cancelGrace();
388
388
  this.disconnectionGrace = setTimeout(() => {
389
- if (this.connection !== void 0) {
390
- this.log?.warn(
391
- `grace period for ${this.to} elapsed while connected. not calling callback`,
392
- {
393
- ...this.loggingMetadata,
394
- connId: this.connection.id,
395
- tags: ["invariant-violation"]
396
- }
397
- );
398
- return;
399
- }
400
389
  this.log?.info(
401
390
  `grace period for ${this.to} elapsed`,
402
391
  this.loggingMetadata
@@ -405,14 +394,8 @@ var Session = class {
405
394
  }, this.options.sessionDisconnectGraceMs);
406
395
  }
407
396
  // called on reconnect of the underlying session
408
- cancelGrace({ keepHeartbeatMisses } = {
409
- keepHeartbeatMisses: false
410
- }) {
411
- if (!keepHeartbeatMisses) {
412
- this.heartbeatMisses = 0;
413
- }
414
- if (this.disconnectionGrace === void 0)
415
- return;
397
+ cancelGrace() {
398
+ this.heartbeatMisses = 0;
416
399
  clearTimeout(this.disconnectionGrace);
417
400
  this.disconnectionGrace = void 0;
418
401
  }
@@ -864,7 +847,7 @@ var Transport = class {
864
847
  * and we know the identity of the connected client.
865
848
  * @param conn The connection object.
866
849
  */
867
- onConnect(conn, connectedTo, session, isReconnect) {
850
+ onConnect(conn, session, isReconnect) {
868
851
  this.eventDispatcher.dispatchEvent("connectionStatus", {
869
852
  status: "connect",
870
853
  conn
@@ -872,13 +855,11 @@ var Transport = class {
872
855
  conn.telemetry = createConnectionTelemetryInfo(conn, session.telemetry);
873
856
  if (isReconnect) {
874
857
  session.replaceWithNewConnection(conn);
875
- this.log?.info(`reconnected to ${connectedTo}`, {
876
- ...conn.loggingMetadata,
877
- ...session.loggingMetadata,
878
- clientId: this.clientId,
879
- connectedTo
880
- });
881
858
  }
859
+ this.log?.info(`connected to ${session.to}`, {
860
+ ...conn.loggingMetadata,
861
+ ...session.loggingMetadata
862
+ });
882
863
  }
883
864
  createSession(to, conn, propagationCtx) {
884
865
  const session = new Session(
@@ -1209,12 +1190,16 @@ var ClientTransport = class extends Transport {
1209
1190
  if (session) {
1210
1191
  this.onDisconnect(conn, session);
1211
1192
  }
1212
- this.log?.info(`connection to ${to} disconnected`, {
1213
- ...conn.loggingMetadata,
1214
- ...session?.loggingMetadata,
1215
- clientId: this.clientId,
1216
- connectedTo: to
1217
- });
1193
+ const willReconnect = this.reconnectOnConnectionDrop && this.getStatus() === "open";
1194
+ this.log?.info(
1195
+ `connection to ${to} disconnected` + (willReconnect ? ", reconnecting" : ""),
1196
+ {
1197
+ ...conn.loggingMetadata,
1198
+ ...session?.loggingMetadata,
1199
+ clientId: this.clientId,
1200
+ connectedTo: to
1201
+ }
1202
+ );
1218
1203
  this.inflightConnectionPromises.delete(to);
1219
1204
  if (this.reconnectOnConnectionDrop) {
1220
1205
  void this.connect(to);
@@ -1300,8 +1285,8 @@ var ClientTransport = class extends Transport {
1300
1285
  conn,
1301
1286
  sessionId: parsed.payload.status.sessionId
1302
1287
  });
1303
- this.onConnect(conn, parsed.from, session, isReconnect);
1304
- this.retryBudget.startRestoringBudget(parsed.from);
1288
+ this.onConnect(conn, session, isReconnect);
1289
+ this.retryBudget.startRestoringBudget(session.to);
1305
1290
  return session;
1306
1291
  }
1307
1292
  /**
@@ -1309,6 +1294,13 @@ var ClientTransport = class extends Transport {
1309
1294
  * @param to The client ID of the node to connect to.
1310
1295
  */
1311
1296
  async connect(to) {
1297
+ if (this.connections.has(to)) {
1298
+ this.log?.info(`already connected to ${to}, skipping connect attempt`, {
1299
+ clientId: this.clientId,
1300
+ connectedTo: to
1301
+ });
1302
+ return;
1303
+ }
1312
1304
  const canProceedWithConnection = () => this.getStatus() === "open";
1313
1305
  if (!canProceedWithConnection()) {
1314
1306
  this.log?.info(
@@ -1319,8 +1311,8 @@ var ClientTransport = class extends Transport {
1319
1311
  }
1320
1312
  let reconnectPromise = this.inflightConnectionPromises.get(to);
1321
1313
  if (!reconnectPromise) {
1322
- const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
1323
1314
  if (!this.retryBudget.hasBudget(to)) {
1315
+ const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
1324
1316
  const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
1325
1317
  this.log?.error(errMsg, { clientId: this.clientId, connectedTo: to });
1326
1318
  this.protocolError(ProtocolError.RetriesExceeded, errMsg);
@@ -1401,7 +1393,7 @@ var ClientTransport = class extends Transport {
1401
1393
  clientId: this.clientId,
1402
1394
  connectedTo: to
1403
1395
  });
1404
- return this.connect(to);
1396
+ await this.connect(to);
1405
1397
  }
1406
1398
  }
1407
1399
  }