@replit/river 0.26.5 → 0.26.7

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 (60) hide show
  1. package/dist/{chunk-FA2IRWCM.js → chunk-C7OSTU6D.js} +2 -2
  2. package/dist/{chunk-XRZ52TYH.js → chunk-F32IOMOX.js} +15 -7
  3. package/dist/chunk-F32IOMOX.js.map +1 -0
  4. package/dist/{chunk-IPOUVVKT.js → chunk-I3Z6XQVK.js} +12 -7
  5. package/dist/chunk-I3Z6XQVK.js.map +1 -0
  6. package/dist/{chunk-PZEYFHAB.js → chunk-JJX4ALPO.js} +11 -8
  7. package/dist/chunk-JJX4ALPO.js.map +1 -0
  8. package/dist/{chunk-QEWSUVWV.js → chunk-KMH4I245.js} +12 -3
  9. package/dist/chunk-KMH4I245.js.map +1 -0
  10. package/dist/{chunk-TAH2GVTJ.js → chunk-KTS4HBYE.js} +1 -1
  11. package/dist/chunk-KTS4HBYE.js.map +1 -0
  12. package/dist/{chunk-7KB7DHFZ.js → chunk-NHM3XC6K.js} +2 -2
  13. package/dist/{chunk-7KB7DHFZ.js.map → chunk-NHM3XC6K.js.map} +1 -1
  14. package/dist/{chunk-AZ3ILPXP.js → chunk-X4TDCNNT.js} +8 -8
  15. package/dist/chunk-X4TDCNNT.js.map +1 -0
  16. package/dist/{client-6c67339a.d.ts → client-1229b53d.d.ts} +2 -2
  17. package/dist/connection-c5ffd44e.d.ts +32 -0
  18. package/dist/{handshake-154a0bb2.d.ts → handshake-02a61755.d.ts} +10 -3
  19. package/dist/logging/index.cjs.map +1 -1
  20. package/dist/logging/index.d.cts +1 -1
  21. package/dist/logging/index.d.ts +1 -1
  22. package/dist/logging/index.js +1 -1
  23. package/dist/{message-ff78a233.d.ts → message-3edb8fac.d.ts} +2 -1
  24. package/dist/router/index.cjs +1 -1
  25. package/dist/router/index.cjs.map +1 -1
  26. package/dist/router/index.d.cts +8 -8
  27. package/dist/router/index.d.ts +8 -8
  28. package/dist/router/index.js +2 -2
  29. package/dist/{server-1f5eb427.d.ts → server-89076d9a.d.ts} +4 -3
  30. package/dist/{services-6140f578.d.ts → services-4478e99b.d.ts} +3 -3
  31. package/dist/transport/impls/ws/client.cjs +39 -14
  32. package/dist/transport/impls/ws/client.cjs.map +1 -1
  33. package/dist/transport/impls/ws/client.d.cts +4 -4
  34. package/dist/transport/impls/ws/client.d.ts +4 -4
  35. package/dist/transport/impls/ws/client.js +6 -6
  36. package/dist/transport/impls/ws/server.cjs +50 -16
  37. package/dist/transport/impls/ws/server.cjs.map +1 -1
  38. package/dist/transport/impls/ws/server.d.cts +6 -5
  39. package/dist/transport/impls/ws/server.d.ts +6 -5
  40. package/dist/transport/impls/ws/server.js +20 -8
  41. package/dist/transport/impls/ws/server.js.map +1 -1
  42. package/dist/transport/index.cjs +33 -17
  43. package/dist/transport/index.cjs.map +1 -1
  44. package/dist/transport/index.d.cts +4 -4
  45. package/dist/transport/index.d.ts +4 -4
  46. package/dist/transport/index.js +6 -6
  47. package/dist/util/testHelpers.cjs +14 -6
  48. package/dist/util/testHelpers.cjs.map +1 -1
  49. package/dist/util/testHelpers.d.cts +4 -4
  50. package/dist/util/testHelpers.d.ts +4 -4
  51. package/dist/util/testHelpers.js +3 -3
  52. package/package.json +1 -1
  53. package/dist/chunk-AZ3ILPXP.js.map +0 -1
  54. package/dist/chunk-IPOUVVKT.js.map +0 -1
  55. package/dist/chunk-PZEYFHAB.js.map +0 -1
  56. package/dist/chunk-QEWSUVWV.js.map +0 -1
  57. package/dist/chunk-TAH2GVTJ.js.map +0 -1
  58. package/dist/chunk-XRZ52TYH.js.map +0 -1
  59. package/dist/connection-03ffb583.d.ts +0 -11
  60. /package/dist/{chunk-FA2IRWCM.js.map → chunk-C7OSTU6D.js.map} +0 -0
@@ -1,14 +1,14 @@
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';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-4478e99b.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-4478e99b.js';
3
3
  import { Static } from '@sinclair/typebox';
4
4
  import { Pushable } from 'it-pushable';
5
- import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-154a0bb2.js';
6
- export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-154a0bb2.js';
7
- import { S as ServerTransport } from '../server-1f5eb427.js';
8
- import '../message-ff78a233.js';
5
+ import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-02a61755.js';
6
+ export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-02a61755.js';
7
+ import { S as ServerTransport } from '../server-89076d9a.js';
8
+ import '../message-3edb8fac.js';
9
9
  import '@sinclair/typebox/value';
10
10
  import '@opentelemetry/api';
11
- import '../client-6c67339a.js';
11
+ import '../client-1229b53d.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.5";
49
+ var version = "0.26.7";
50
50
 
51
51
  export { PayloadType, version as RIVER_VERSION, Result, RiverError, Server, ServiceContext, createServer };
@@ -1,14 +1,14 @@
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';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-4478e99b.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-4478e99b.js';
3
3
  import { Static } from '@sinclair/typebox';
4
4
  import { Pushable } from 'it-pushable';
5
- import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-154a0bb2.js';
6
- export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-154a0bb2.js';
7
- import { S as ServerTransport } from '../server-1f5eb427.js';
8
- import '../message-ff78a233.js';
5
+ import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-02a61755.js';
6
+ export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-02a61755.js';
7
+ import { S as ServerTransport } from '../server-89076d9a.js';
8
+ import '../message-3edb8fac.js';
9
9
  import '@sinclair/typebox/value';
10
10
  import '@opentelemetry/api';
11
- import '../client-6c67339a.js';
11
+ import '../client-1229b53d.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.5";
49
+ var version = "0.26.7";
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-FA2IRWCM.js";
13
+ } from "../chunk-C7OSTU6D.js";
14
14
  import {
15
15
  version
16
- } from "../chunk-7KB7DHFZ.js";
16
+ } from "../chunk-NHM3XC6K.js";
17
17
  export {
18
18
  Err,
19
19
  Ok,
@@ -1,5 +1,5 @@
1
- import { C as Connection, y as CommonSession, d as SessionState, z as CommonSessionProps, T as Transport, A as ServerTransportOptions, s as ServerHandshakeOptions, t as ParsedMetadata, B as ServerSession, c as ProvidedServerTransportOptions } from './handshake-154a0bb2.js';
2
- import { b as OpaqueTransportMessage, e as Tags, a as TransportMessage, H as HandshakeErrorResponseCodes, c as TransportClientId, P as PartialTransportMessage } from './message-ff78a233.js';
1
+ import { C as Connection, y as CommonSession, d as SessionState, z as CommonSessionProps, T as Transport, A as ServerTransportOptions, s as ServerHandshakeOptions, t as ParsedMetadata, B as ServerSession, c as ProvidedServerTransportOptions, D as DeleteSessionOptions } from './handshake-02a61755.js';
2
+ import { b as OpaqueTransportMessage, e as Tags, a as TransportMessage, H as HandshakeErrorResponseCodes, c as TransportClientId, P as PartialTransportMessage } from './message-3edb8fac.js';
3
3
  import * as _sinclair_typebox_errors from '@sinclair/typebox/errors';
4
4
  import { Static } from '@sinclair/typebox';
5
5
 
@@ -33,6 +33,7 @@ declare class SessionWaitingForHandshake<ConnType extends Connection> extends Co
33
33
  traceId: string;
34
34
  spanId: string;
35
35
  } | undefined;
36
+ extras?: unknown;
36
37
  };
37
38
  onHandshakeData: (msg: Uint8Array) => void;
38
39
  sendHandshake(msg: TransportMessage): boolean;
@@ -59,7 +60,7 @@ declare abstract class ServerTransport<ConnType extends Connection> extends Tran
59
60
  extendHandshake(options: ServerHandshakeOptions): void;
60
61
  send(to: string, msg: PartialTransportMessage): string;
61
62
  protected deletePendingSession(pendingSession: SessionWaitingForHandshake<ConnType>): void;
62
- protected deleteSession(session: ServerSession<ConnType>): void;
63
+ protected deleteSession(session: ServerSession<ConnType>, options?: DeleteSessionOptions): void;
63
64
  protected handleConnection(conn: ConnType): void;
64
65
  private rejectHandshakeRequest;
65
66
  protected onHandshakeRequest(session: SessionWaitingForHandshake<ConnType>, msg: OpaqueTransportMessage): Promise<void>;
@@ -1,8 +1,8 @@
1
1
  import { Static, TObject, TUnion, TString, TSchema, TNever, TLiteral } from '@sinclair/typebox';
2
2
  import { Pushable } from 'it-pushable';
3
- import { C as Connection, p as ClientHandshakeOptions, v as ServiceContextWithTransportInfo, o as ServiceContext } from './handshake-154a0bb2.js';
4
- import { c as TransportClientId } from './message-ff78a233.js';
5
- import { C as ClientTransport } from './client-6c67339a.js';
3
+ import { C as Connection, p as ClientHandshakeOptions, v as ServiceContextWithTransportInfo, o as ServiceContext } from './handshake-02a61755.js';
4
+ import { c as TransportClientId } from './message-3edb8fac.js';
5
+ import { C as ClientTransport } from './client-1229b53d.js';
6
6
 
7
7
  type AsyncIter<T> = AsyncGenerator<T, T>;
8
8
  /**
@@ -355,7 +355,8 @@ var createLogProxy = (log) => ({
355
355
  var ProtocolError = {
356
356
  RetriesExceeded: "conn_retry_exceeded",
357
357
  HandshakeFailed: "handshake_failed",
358
- MessageOrderingViolated: "message_ordering_violated"
358
+ MessageOrderingViolated: "message_ordering_violated",
359
+ InvalidMessage: "invalid_message"
359
360
  };
360
361
  var EventDispatcher = class {
361
362
  eventListeners = {};
@@ -631,7 +632,7 @@ var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
631
632
  var import_api = require("@opentelemetry/api");
632
633
 
633
634
  // package.json
634
- var version = "0.26.5";
635
+ var version = "0.26.7";
635
636
 
636
637
  // tracing/index.ts
637
638
  function getPropagationContext(ctx) {
@@ -841,6 +842,12 @@ var SessionConnected = class extends IdentifiedSession {
841
842
  }
842
843
  });
843
844
  }
845
+ closeConnection() {
846
+ this.conn.removeDataListener(this.onMessageData);
847
+ this.conn.removeCloseListener(this.listeners.onConnectionClosed);
848
+ this.conn.removeErrorListener(this.listeners.onConnectionErrored);
849
+ this.conn.close();
850
+ }
844
851
  onMessageData = (msg) => {
845
852
  const parsedMsg = this.parseMsg(msg);
846
853
  if (parsedMsg === null) {
@@ -857,8 +864,8 @@ var SessionConnected = class extends IdentifiedSession {
857
864
  }
858
865
  );
859
866
  } else {
860
- const reason = `received out-of-order msg (got seq: ${parsedMsg.seq}, wanted seq: ${this.ack})`;
861
- this.log?.error(reason, {
867
+ const reason = `received out-of-order msg, closing connection (got seq: ${parsedMsg.seq}, wanted seq: ${this.ack})`;
868
+ this.log?.warn(reason, {
862
869
  ...this.loggingMetadata,
863
870
  transportMessage: parsedMsg,
864
871
  tags: ["invariant-violation"]
@@ -867,7 +874,7 @@ var SessionConnected = class extends IdentifiedSession {
867
874
  code: import_api2.SpanStatusCode.ERROR,
868
875
  message: reason
869
876
  });
870
- this.listeners.onInvalidMessage(reason);
877
+ this.closeConnection();
871
878
  }
872
879
  return;
873
880
  }
@@ -893,8 +900,10 @@ var SessionConnected = class extends IdentifiedSession {
893
900
  this.conn.removeDataListener(this.onMessageData);
894
901
  this.conn.removeCloseListener(this.listeners.onConnectionClosed);
895
902
  this.conn.removeErrorListener(this.listeners.onConnectionErrored);
896
- clearInterval(this.heartbeatHandle);
897
- this.heartbeatHandle = void 0;
903
+ if (this.heartbeatHandle) {
904
+ clearInterval(this.heartbeatHandle);
905
+ this.heartbeatHandle = void 0;
906
+ }
898
907
  }
899
908
  _handleClose() {
900
909
  super._handleClose();
@@ -1323,8 +1332,12 @@ var Transport = class {
1323
1332
  return session;
1324
1333
  }
1325
1334
  // state transitions
1326
- deleteSession(session) {
1327
- session.log?.info(`closing session ${session.id}`, session.loggingMetadata);
1335
+ deleteSession(session, options) {
1336
+ const loggingMetadata = session.loggingMetadata;
1337
+ if (loggingMetadata.tags && options?.unhealthy) {
1338
+ loggingMetadata.tags.push("unhealthy-session");
1339
+ }
1340
+ session.log?.info(`closing session ${session.id}`, loggingMetadata);
1328
1341
  this.eventDispatcher.dispatchEvent("sessionStatus", {
1329
1342
  status: "disconnect",
1330
1343
  session
@@ -1486,7 +1499,7 @@ var ClientTransport = class extends Transport {
1486
1499
  `invalid handshake: ${reason}`,
1487
1500
  handshakingSession.loggingMetadata
1488
1501
  );
1489
- this.deleteSession(session);
1502
+ this.deleteSession(session, { unhealthy: true });
1490
1503
  this.protocolError({
1491
1504
  type: ProtocolError.HandshakeFailed,
1492
1505
  code,
@@ -1515,7 +1528,7 @@ var ClientTransport = class extends Transport {
1515
1528
  message: reason
1516
1529
  });
1517
1530
  this.log?.warn(reason, metadata);
1518
- this.deleteSession(session);
1531
+ this.deleteSession(session, { unhealthy: true });
1519
1532
  }
1520
1533
  onHandshakeResponse(session, msg) {
1521
1534
  if (!import_value2.Value.Check(ControlMessageHandshakeResponseSchema, msg.payload)) {
@@ -1580,9 +1593,9 @@ var ClientTransport = class extends Transport {
1580
1593
  },
1581
1594
  onMessage: (msg2) => this.handleMsg(msg2),
1582
1595
  onInvalidMessage: (reason) => {
1583
- this.deleteSession(connectedSession);
1596
+ this.deleteSession(connectedSession, { unhealthy: true });
1584
1597
  this.protocolError({
1585
- type: ProtocolError.MessageOrderingViolated,
1598
+ type: ProtocolError.InvalidMessage,
1586
1599
  message: reason
1587
1600
  });
1588
1601
  }
@@ -1694,6 +1707,9 @@ var ClientTransport = class extends Transport {
1694
1707
  if (this.handshakeExtensions) {
1695
1708
  metadata = await this.handshakeExtensions.construct();
1696
1709
  }
1710
+ if (session._isConsumed) {
1711
+ return;
1712
+ }
1697
1713
  const requestMsg = handshakeRequestMessage({
1698
1714
  from: this.clientId,
1699
1715
  to: session.to,
@@ -1791,9 +1807,18 @@ var Connection = class {
1791
1807
  // transport/impls/ws/connection.ts
1792
1808
  var WebSocketConnection = class extends Connection {
1793
1809
  ws;
1794
- constructor(ws) {
1810
+ extras;
1811
+ get loggingMetadata() {
1812
+ const metadata = super.loggingMetadata;
1813
+ if (this.extras) {
1814
+ metadata.extras = this.extras;
1815
+ }
1816
+ return metadata;
1817
+ }
1818
+ constructor(ws, extras) {
1795
1819
  super();
1796
1820
  this.ws = ws;
1821
+ this.extras = extras;
1797
1822
  this.ws.binaryType = "arraybuffer";
1798
1823
  let didError = false;
1799
1824
  this.ws.onerror = () => {