@replit/river 0.206.0 → 0.207.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 (39) hide show
  1. package/dist/{chunk-JSU537MZ.js → chunk-24EWYOGK.js} +27 -11
  2. package/dist/chunk-24EWYOGK.js.map +1 -0
  3. package/dist/{chunk-NTVJNU5K.js → chunk-46IVOKJU.js} +2 -11
  4. package/dist/{chunk-NTVJNU5K.js.map → chunk-46IVOKJU.js.map} +1 -1
  5. package/dist/{chunk-VGWFMCOP.js → chunk-4HE7UYRL.js} +2 -2
  6. package/dist/{chunk-FCQWZRES.js → chunk-A7RGOVRV.js} +3 -3
  7. package/dist/{chunk-EMOYAUX3.js → chunk-XV4RQ62N.js} +3 -3
  8. package/dist/{connection-494a5b68.d.ts → connection-a18e31d5.d.ts} +1 -1
  9. package/dist/router/index.cjs +3 -13
  10. package/dist/router/index.cjs.map +1 -1
  11. package/dist/router/index.d.cts +3 -3
  12. package/dist/router/index.d.ts +3 -3
  13. package/dist/router/index.js +2 -4
  14. package/dist/{services-15a0df95.d.ts → services-43528f4b.d.ts} +3 -9
  15. package/dist/testUtil/index.cjs +26 -10
  16. package/dist/testUtil/index.cjs.map +1 -1
  17. package/dist/testUtil/index.d.cts +1 -1
  18. package/dist/testUtil/index.d.ts +1 -1
  19. package/dist/testUtil/index.js +4 -4
  20. package/dist/transport/impls/ws/client.cjs +26 -10
  21. package/dist/transport/impls/ws/client.cjs.map +1 -1
  22. package/dist/transport/impls/ws/client.d.cts +2 -2
  23. package/dist/transport/impls/ws/client.d.ts +2 -2
  24. package/dist/transport/impls/ws/client.js +4 -4
  25. package/dist/transport/impls/ws/server.cjs +26 -10
  26. package/dist/transport/impls/ws/server.cjs.map +1 -1
  27. package/dist/transport/impls/ws/server.d.cts +2 -2
  28. package/dist/transport/impls/ws/server.d.ts +2 -2
  29. package/dist/transport/impls/ws/server.js +4 -4
  30. package/dist/transport/index.cjs +26 -10
  31. package/dist/transport/index.cjs.map +1 -1
  32. package/dist/transport/index.d.cts +2 -2
  33. package/dist/transport/index.d.ts +2 -2
  34. package/dist/transport/index.js +4 -4
  35. package/package.json +1 -1
  36. package/dist/chunk-JSU537MZ.js.map +0 -1
  37. /package/dist/{chunk-VGWFMCOP.js.map → chunk-4HE7UYRL.js.map} +0 -0
  38. /package/dist/{chunk-FCQWZRES.js.map → chunk-A7RGOVRV.js.map} +0 -0
  39. /package/dist/{chunk-EMOYAUX3.js.map → chunk-XV4RQ62N.js.map} +0 -0
@@ -1,5 +1,5 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, c as ParsedMetadata, d as AnyProcedure, b as Connection, S as ServerHandshakeOptions, e as ServiceContext } from '../services-15a0df95.js';
2
- export { M as BaseErrorSchemaType, K as CANCEL_CODE, O as Client, X as Err, _ as ErrResult, J as INVALID_REQUEST_CODE, T as Ok, $ as OkResult, w as PayloadType, l as ProcErrors, h as ProcHandler, i as ProcInit, j as ProcRequest, k as ProcResponse, m as ProcType, D as Procedure, E as ProcedureErrorSchemaType, Q as ProcedureHandlerContext, x as ProcedureMap, R as RPCProcedure, B as Readable, L as ReaderErrorSchema, a2 as ResponseData, Z as Result, a1 as ResultUnwrapErr, a0 as ResultUnwrapOk, q as SerializedProcedureSchema, v as SerializedProcedureSchemaProtocolv1, o as SerializedServerSchema, t as SerializedServerSchemaProtocolv1, p as SerializedServiceSchema, u as SerializedServiceSchemaProtocolv1, f as Service, g as ServiceConfiguration, n as ServiceSchema, z as StreamProcedure, y as SubscriptionProcedure, G as UNCAUGHT_ERROR_CODE, H as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, N as createClient, a3 as createClientHandshakeOptions, a4 as createServerHandshakeOptions, F as flattenErrorType, s as serializeSchema, r as serializeSchemaV1Compat, Y as unwrapOrThrow } from '../services-15a0df95.js';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, c as ParsedMetadata, d as AnyProcedure, b as Connection, S as ServerHandshakeOptions, e as ServiceContext } from '../services-43528f4b.js';
2
+ export { M as BaseErrorSchemaType, K as CANCEL_CODE, O as Client, X as Err, Z as ErrResult, J as INVALID_REQUEST_CODE, T as Ok, _ as OkResult, w as PayloadType, l as ProcErrors, h as ProcHandler, i as ProcInit, j as ProcRequest, k as ProcResponse, m as ProcType, D as Procedure, E as ProcedureErrorSchemaType, Q as ProcedureHandlerContext, x as ProcedureMap, R as RPCProcedure, B as Readable, L as ReaderErrorSchema, a1 as ResponseData, Y as Result, a0 as ResultUnwrapErr, $ as ResultUnwrapOk, q as SerializedProcedureSchema, v as SerializedProcedureSchemaProtocolv1, o as SerializedServerSchema, t as SerializedServerSchemaProtocolv1, p as SerializedServiceSchema, u as SerializedServiceSchemaProtocolv1, f as Service, g as ServiceConfiguration, n as ServiceSchema, z as StreamProcedure, y as SubscriptionProcedure, G as UNCAUGHT_ERROR_CODE, H as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, N as createClient, a2 as createClientHandshakeOptions, a3 as createServerHandshakeOptions, F as flattenErrorType, s as serializeSchema, r as serializeSchemaV1Compat } from '../services-43528f4b.js';
3
3
  import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-ffacb98a.js';
4
4
  import { ServerTransport } from '../transport/index.cjs';
5
5
  import '@sinclair/typebox';
@@ -51,6 +51,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
51
51
  maxCancelledStreamTombstonesPerSession?: number;
52
52
  }>): Server<Services>;
53
53
 
54
- var version = "0.206.0";
54
+ var version = "0.207.2";
55
55
 
56
56
  export { ParsedMetadata, version as RIVER_VERSION, Server, ServiceContext, createServer };
@@ -1,5 +1,5 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, c as ParsedMetadata, d as AnyProcedure, b as Connection, S as ServerHandshakeOptions, e as ServiceContext } from '../services-15a0df95.js';
2
- export { M as BaseErrorSchemaType, K as CANCEL_CODE, O as Client, X as Err, _ as ErrResult, J as INVALID_REQUEST_CODE, T as Ok, $ as OkResult, w as PayloadType, l as ProcErrors, h as ProcHandler, i as ProcInit, j as ProcRequest, k as ProcResponse, m as ProcType, D as Procedure, E as ProcedureErrorSchemaType, Q as ProcedureHandlerContext, x as ProcedureMap, R as RPCProcedure, B as Readable, L as ReaderErrorSchema, a2 as ResponseData, Z as Result, a1 as ResultUnwrapErr, a0 as ResultUnwrapOk, q as SerializedProcedureSchema, v as SerializedProcedureSchemaProtocolv1, o as SerializedServerSchema, t as SerializedServerSchemaProtocolv1, p as SerializedServiceSchema, u as SerializedServiceSchemaProtocolv1, f as Service, g as ServiceConfiguration, n as ServiceSchema, z as StreamProcedure, y as SubscriptionProcedure, G as UNCAUGHT_ERROR_CODE, H as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, N as createClient, a3 as createClientHandshakeOptions, a4 as createServerHandshakeOptions, F as flattenErrorType, s as serializeSchema, r as serializeSchemaV1Compat, Y as unwrapOrThrow } from '../services-15a0df95.js';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, c as ParsedMetadata, d as AnyProcedure, b as Connection, S as ServerHandshakeOptions, e as ServiceContext } from '../services-43528f4b.js';
2
+ export { M as BaseErrorSchemaType, K as CANCEL_CODE, O as Client, X as Err, Z as ErrResult, J as INVALID_REQUEST_CODE, T as Ok, _ as OkResult, w as PayloadType, l as ProcErrors, h as ProcHandler, i as ProcInit, j as ProcRequest, k as ProcResponse, m as ProcType, D as Procedure, E as ProcedureErrorSchemaType, Q as ProcedureHandlerContext, x as ProcedureMap, R as RPCProcedure, B as Readable, L as ReaderErrorSchema, a1 as ResponseData, Y as Result, a0 as ResultUnwrapErr, $ as ResultUnwrapOk, q as SerializedProcedureSchema, v as SerializedProcedureSchemaProtocolv1, o as SerializedServerSchema, t as SerializedServerSchemaProtocolv1, p as SerializedServiceSchema, u as SerializedServiceSchemaProtocolv1, f as Service, g as ServiceConfiguration, n as ServiceSchema, z as StreamProcedure, y as SubscriptionProcedure, G as UNCAUGHT_ERROR_CODE, H as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, N as createClient, a2 as createClientHandshakeOptions, a3 as createServerHandshakeOptions, F as flattenErrorType, s as serializeSchema, r as serializeSchemaV1Compat } from '../services-43528f4b.js';
3
3
  import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-ffacb98a.js';
4
4
  import { ServerTransport } from '../transport/index.js';
5
5
  import '@sinclair/typebox';
@@ -51,6 +51,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
51
51
  maxCancelledStreamTombstonesPerSession?: number;
52
52
  }>): Server<Services>;
53
53
 
54
- var version = "0.206.0";
54
+ var version = "0.207.2";
55
55
 
56
56
  export { ParsedMetadata, version as RIVER_VERSION, Server, ServiceContext, createServer };
@@ -15,9 +15,8 @@ import {
15
15
  flattenErrorType,
16
16
  serializeSchema,
17
17
  serializeSchemaV1Compat,
18
- unwrapOrThrow,
19
18
  version
20
- } from "../chunk-NTVJNU5K.js";
19
+ } from "../chunk-46IVOKJU.js";
21
20
  export {
22
21
  CANCEL_CODE,
23
22
  Err,
@@ -35,7 +34,6 @@ export {
35
34
  createServerHandshakeOptions,
36
35
  flattenErrorType,
37
36
  serializeSchema,
38
- serializeSchemaV1Compat,
39
- unwrapOrThrow
37
+ serializeSchemaV1Compat
40
38
  };
41
39
  //# sourceMappingURL=index.js.map
@@ -273,6 +273,8 @@ declare class SessionConnected<ConnType extends Connection> extends IdentifiedSe
273
273
  private heartbeatHandle?;
274
274
  private heartbeatMisses;
275
275
  isActivelyHeartbeating: boolean;
276
+ private lastConstructedMsgs;
277
+ private pushLastConstructedMsgs;
276
278
  updateBookkeeping(ack: number, seq: number): void;
277
279
  private assertSendOrdering;
278
280
  send(msg: PartialTransportMessage): string;
@@ -297,7 +299,6 @@ declare class SessionConnected<ConnType extends Connection> extends IdentifiedSe
297
299
  };
298
300
  startActiveHeartbeat(): void;
299
301
  private sendHeartbeat;
300
- closeConnection(): void;
301
302
  onMessageData: (msg: Uint8Array) => void;
302
303
  _handleStateExit(): void;
303
304
  _handleClose(): void;
@@ -874,13 +875,6 @@ declare function Err<const Err extends Static<BaseErrorSchemaType>>(error: Err):
874
875
  * Refine a {@link Result} type to its returned payload.
875
876
  */
876
877
  type ResultUnwrapOk<R> = R extends Result<infer T, infer __E> ? T : never;
877
- /**
878
- * Unwrap a {@link Result} type and return the payload if successful,
879
- * otherwise throws an error.
880
- * @param result - The result to unwrap.
881
- * @throws Will throw an error if the result is not ok.
882
- */
883
- declare function unwrapOrThrow<T, Err extends Static<BaseErrorSchemaType>>(result: Result<T, Err>): T;
884
878
  /**
885
879
  * Refine a {@link Result} type to its error payload.
886
880
  */
@@ -1568,4 +1562,4 @@ declare class ServiceScaffold<State extends object> {
1568
1562
  }>;
1569
1563
  }
1570
1564
 
1571
- export { OkResult as $, AnyServiceSchemaMap as A, Readable as B, ClientTransport as C, Procedure as D, ProcedureErrorSchemaType as E, flattenErrorType as F, UNCAUGHT_ERROR_CODE as G, UNEXPECTED_DISCONNECT_CODE as H, InstantiatedServiceSchemaMap as I, INVALID_REQUEST_CODE as J, CANCEL_CODE as K, ReaderErrorSchema as L, BaseErrorSchemaType as M, createClient as N, Client as O, ProvidedClientTransportOptions as P, ProcedureHandlerContext as Q, RpcProcedure as R, ServerHandshakeOptions as S, Ok as T, UploadProcedure as U, ValidProcType as V, Writable as W, Err as X, unwrapOrThrow as Y, Result as Z, ErrResult as _, ProvidedServerTransportOptions as a, ResultUnwrapOk as a0, ResultUnwrapErr as a1, ResponseData as a2, createClientHandshakeOptions as a3, createServerHandshakeOptions as a4, ClientHandshakeOptions as a5, ReadableIterator as a6, ReadableResult as a7, Transport as a8, SessionOptions as a9, ClientTransportOptions as aa, SessionNoConnection as ab, SessionBoundSendFn as ac, CommonSession as ad, SessionState as ae, CommonSessionProps as af, ServerTransportOptions as ag, ServerSession as ah, DeleteSessionOptions as ai, TransportStatus as aj, ProvidedTransportOptions as ak, Session as al, SessionConnecting as am, SessionHandshaking as an, SessionConnected as ao, EventMap as ap, EventTypes as aq, EventHandler as ar, ProtocolError as as, ProtocolErrorType as at, Connection as b, ParsedMetadata as c, AnyProcedure as d, ServiceContext as e, Service as f, ServiceConfiguration as g, ProcHandler as h, ProcInit as i, ProcRequest as j, ProcResponse as k, ProcErrors as l, ProcType as m, ServiceSchema as n, SerializedServerSchema as o, SerializedServiceSchema as p, SerializedProcedureSchema as q, serializeSchemaV1Compat as r, serializeSchema as s, SerializedServerSchemaProtocolv1 as t, SerializedServiceSchemaProtocolv1 as u, SerializedProcedureSchemaProtocolv1 as v, PayloadType as w, ProcedureMap as x, SubscriptionProcedure as y, StreamProcedure as z };
1565
+ export { ResultUnwrapOk as $, AnyServiceSchemaMap as A, Readable as B, ClientTransport as C, Procedure as D, ProcedureErrorSchemaType as E, flattenErrorType as F, UNCAUGHT_ERROR_CODE as G, UNEXPECTED_DISCONNECT_CODE as H, InstantiatedServiceSchemaMap as I, INVALID_REQUEST_CODE as J, CANCEL_CODE as K, ReaderErrorSchema as L, BaseErrorSchemaType as M, createClient as N, Client as O, ProvidedClientTransportOptions as P, ProcedureHandlerContext as Q, RpcProcedure as R, ServerHandshakeOptions as S, Ok as T, UploadProcedure as U, ValidProcType as V, Writable as W, Err as X, Result as Y, ErrResult as Z, OkResult as _, ProvidedServerTransportOptions as a, ResultUnwrapErr as a0, ResponseData as a1, createClientHandshakeOptions as a2, createServerHandshakeOptions as a3, ClientHandshakeOptions as a4, ReadableIterator as a5, ReadableResult as a6, Transport as a7, SessionOptions as a8, ClientTransportOptions as a9, SessionNoConnection as aa, SessionBoundSendFn as ab, CommonSession as ac, SessionState as ad, CommonSessionProps as ae, ServerTransportOptions as af, ServerSession as ag, DeleteSessionOptions as ah, TransportStatus as ai, ProvidedTransportOptions as aj, Session as ak, SessionConnecting as al, SessionHandshaking as am, SessionConnected as an, EventMap as ao, EventTypes as ap, EventHandler as aq, ProtocolError as ar, ProtocolErrorType as as, Connection as b, ParsedMetadata as c, AnyProcedure as d, ServiceContext as e, Service as f, ServiceConfiguration as g, ProcHandler as h, ProcInit as i, ProcRequest as j, ProcResponse as k, ProcErrors as l, ProcType as m, ServiceSchema as n, SerializedServerSchema as o, SerializedServiceSchema as p, SerializedProcedureSchema as q, serializeSchemaV1Compat as r, serializeSchema as s, SerializedServerSchemaProtocolv1 as t, SerializedServiceSchemaProtocolv1 as u, SerializedProcedureSchemaProtocolv1 as v, PayloadType as w, ProcedureMap as x, SubscriptionProcedure as y, StreamProcedure as z };
@@ -428,6 +428,9 @@ var IdentifiedSession = class extends CommonSession {
428
428
  return metadata;
429
429
  }
430
430
  constructMsg(partialMsg) {
431
+ if (this._isConsumed) {
432
+ throw new Error(ERR_CONSUMED);
433
+ }
431
434
  const msg = {
432
435
  ...partialMsg,
433
436
  id: generateId(),
@@ -557,7 +560,7 @@ function coerceErrorString(err) {
557
560
  }
558
561
 
559
562
  // package.json
560
- var version = "0.206.0";
563
+ var version = "0.207.2";
561
564
 
562
565
  // tracing/index.ts
563
566
  function getPropagationContext(ctx) {
@@ -716,6 +719,19 @@ var SessionConnected = class extends IdentifiedSession {
716
719
  heartbeatHandle;
717
720
  heartbeatMisses = 0;
718
721
  isActivelyHeartbeating;
722
+ lastConstructedMsgs = [];
723
+ pushLastConstructedMsgs = (msg) => {
724
+ const trackedMsg = {
725
+ id: msg.id,
726
+ seq: msg.seq,
727
+ streamId: msg.streamId,
728
+ stack: new Error().stack
729
+ };
730
+ this.lastConstructedMsgs.push(trackedMsg);
731
+ if (this.lastConstructedMsgs.length > 10) {
732
+ this.lastConstructedMsgs.shift();
733
+ }
734
+ };
719
735
  updateBookkeeping(ack, seq) {
720
736
  this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
721
737
  this.ack = seq + 1;
@@ -727,13 +743,17 @@ var SessionConnected = class extends IdentifiedSession {
727
743
  this.log?.error(msg, {
728
744
  ...this.loggingMetadata,
729
745
  transportMessage: constructedMsg,
730
- tags: ["invariant-violation"]
746
+ tags: ["invariant-violation"],
747
+ extras: {
748
+ lastConstructedMsgs: this.lastConstructedMsgs
749
+ }
731
750
  });
732
751
  throw new Error(msg);
733
752
  }
734
753
  }
735
754
  send(msg) {
736
755
  const constructedMsg = this.constructMsg(msg);
756
+ this.pushLastConstructedMsgs(constructedMsg);
737
757
  this.assertSendOrdering(constructedMsg);
738
758
  this.sendBuffer.push(constructedMsg);
739
759
  this.conn.send(this.options.codec.toBuffer(constructedMsg));
@@ -798,12 +818,6 @@ var SessionConnected = class extends IdentifiedSession {
798
818
  }
799
819
  });
800
820
  }
801
- closeConnection() {
802
- this.conn.removeDataListener(this.onMessageData);
803
- this.conn.removeCloseListener(this.listeners.onConnectionClosed);
804
- this.conn.removeErrorListener(this.listeners.onConnectionErrored);
805
- this.conn.close();
806
- }
807
821
  onMessageData = (msg) => {
808
822
  const parsedMsg = this.parseMsg(msg);
809
823
  if (parsedMsg === null) {
@@ -830,7 +844,7 @@ var SessionConnected = class extends IdentifiedSession {
830
844
  code: import_api2.SpanStatusCode.ERROR,
831
845
  message: reason
832
846
  });
833
- this.closeConnection();
847
+ this.conn.close();
834
848
  }
835
849
  return;
836
850
  }
@@ -848,7 +862,9 @@ var SessionConnected = class extends IdentifiedSession {
848
862
  transportMessage: parsedMsg
849
863
  });
850
864
  if (!this.isActivelyHeartbeating) {
851
- this.sendHeartbeat();
865
+ void Promise.resolve().then(() => {
866
+ this.sendHeartbeat();
867
+ });
852
868
  }
853
869
  };
854
870
  _handleStateExit() {