@replit/river 0.205.1 → 0.205.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 (43) hide show
  1. package/dist/{chunk-HNBYBRJ7.js → chunk-BYA34LH3.js} +2 -2
  2. package/dist/{chunk-HNBYBRJ7.js.map → chunk-BYA34LH3.js.map} +1 -1
  3. package/dist/{chunk-356UADV3.js → chunk-FCN2JPOE.js} +2 -2
  4. package/dist/{chunk-Y2N4EJYG.js → chunk-FTOB2HQN.js} +39 -6
  5. package/dist/chunk-FTOB2HQN.js.map +1 -0
  6. package/dist/{chunk-OVLZDQF4.js → chunk-TP4OJAKI.js} +4 -4
  7. package/dist/{chunk-OVLZDQF4.js.map → chunk-TP4OJAKI.js.map} +1 -1
  8. package/dist/{chunk-3XCLUGDM.js → chunk-W337YQLT.js} +3 -3
  9. package/dist/{client-c44d1c69.d.ts → client-8ab60722.d.ts} +1 -1
  10. package/dist/{connection-03726441.d.ts → connection-8ed39cb5.d.ts} +1 -1
  11. package/dist/{context-ebf88958.d.ts → context-2c4bb66b.d.ts} +11 -0
  12. package/dist/router/index.cjs +1 -1
  13. package/dist/router/index.cjs.map +1 -1
  14. package/dist/router/index.d.cts +7 -7
  15. package/dist/router/index.d.ts +7 -7
  16. package/dist/router/index.js +1 -1
  17. package/dist/{server-b169b234.d.ts → server-dc261419.d.ts} +1 -1
  18. package/dist/{services-47b312aa.d.ts → services-036dcc97.d.ts} +2 -2
  19. package/dist/testUtil/index.cjs +43 -7
  20. package/dist/testUtil/index.cjs.map +1 -1
  21. package/dist/testUtil/index.d.cts +4 -4
  22. package/dist/testUtil/index.d.ts +4 -4
  23. package/dist/testUtil/index.js +8 -5
  24. package/dist/testUtil/index.js.map +1 -1
  25. package/dist/transport/impls/ws/client.cjs +38 -5
  26. package/dist/transport/impls/ws/client.cjs.map +1 -1
  27. package/dist/transport/impls/ws/client.d.cts +3 -3
  28. package/dist/transport/impls/ws/client.d.ts +3 -3
  29. package/dist/transport/impls/ws/client.js +4 -4
  30. package/dist/transport/impls/ws/server.cjs +39 -6
  31. package/dist/transport/impls/ws/server.cjs.map +1 -1
  32. package/dist/transport/impls/ws/server.d.cts +3 -3
  33. package/dist/transport/impls/ws/server.d.ts +3 -3
  34. package/dist/transport/impls/ws/server.js +4 -4
  35. package/dist/transport/index.cjs +39 -6
  36. package/dist/transport/index.cjs.map +1 -1
  37. package/dist/transport/index.d.cts +3 -3
  38. package/dist/transport/index.d.ts +3 -3
  39. package/dist/transport/index.js +4 -4
  40. package/package.json +4 -4
  41. package/dist/chunk-Y2N4EJYG.js.map +0 -1
  42. /package/dist/{chunk-356UADV3.js.map → chunk-FCN2JPOE.js.map} +0 -0
  43. /package/dist/{chunk-3XCLUGDM.js.map → chunk-W337YQLT.js.map} +0 -0
@@ -1,11 +1,11 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, a as AnyProcedure } from '../services-47b312aa.js';
2
- export { E as BaseErrorSchemaType, C as CANCEL_CODE, G as Client, H as Err, L as ErrResult, B as INVALID_REQUEST_CODE, O as Ok, M as OkResult, p as PayloadType, f as ProcErrors, P as ProcHandler, c as ProcInit, d as ProcRequest, e as ProcResponse, g as ProcType, v as Procedure, w as ProcedureErrorSchemaType, q as ProcedureMap, R as RPCProcedure, u as Readable, D as ReaderErrorSchema, T as ResponseData, K as Result, Q as ResultUnwrapErr, N as ResultUnwrapOk, k as SerializedProcedureSchema, o as SerializedProcedureSchemaProtocolv1, i as SerializedServerSchema, m as SerializedServerSchemaProtocolv1, j as SerializedServiceSchema, n as SerializedServiceSchemaProtocolv1, S as Service, b as ServiceConfiguration, h as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, y as UNCAUGHT_ERROR_CODE, z as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, F as createClient, x as flattenErrorType, s as serializeSchema, l as serializeSchemaV1Compat, J as unwrapOrThrow } from '../services-47b312aa.js';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, a as AnyProcedure } from '../services-036dcc97.js';
2
+ export { E as BaseErrorSchemaType, C as CANCEL_CODE, G as Client, H as Err, L as ErrResult, B as INVALID_REQUEST_CODE, O as Ok, M as OkResult, p as PayloadType, f as ProcErrors, P as ProcHandler, c as ProcInit, d as ProcRequest, e as ProcResponse, g as ProcType, v as Procedure, w as ProcedureErrorSchemaType, q as ProcedureMap, R as RPCProcedure, u as Readable, D as ReaderErrorSchema, T as ResponseData, K as Result, Q as ResultUnwrapErr, N as ResultUnwrapOk, k as SerializedProcedureSchema, o as SerializedProcedureSchemaProtocolv1, i as SerializedServerSchema, m as SerializedServerSchemaProtocolv1, j as SerializedServiceSchema, n as SerializedServiceSchemaProtocolv1, S as Service, b as ServiceConfiguration, h as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, y as UNCAUGHT_ERROR_CODE, z as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, F as createClient, x as flattenErrorType, s as serializeSchema, l as serializeSchemaV1Compat, J as unwrapOrThrow } from '../services-036dcc97.js';
3
3
  import { c as TransportClientId, b as OpaqueTransportMessage } from '../message-865bba35.js';
4
- import { q as ParsedMetadata, C as Connection, r as ServerHandshakeOptions, s as ServiceContext } from '../context-ebf88958.js';
5
- export { t as ProcedureHandlerContext, u as createClientHandshakeOptions, v as createServerHandshakeOptions } from '../context-ebf88958.js';
6
- import { S as ServerTransport } from '../server-b169b234.js';
4
+ import { q as ParsedMetadata, C as Connection, r as ServerHandshakeOptions, s as ServiceContext } from '../context-2c4bb66b.js';
5
+ export { t as ProcedureHandlerContext, u as createClientHandshakeOptions, v as createServerHandshakeOptions } from '../context-2c4bb66b.js';
6
+ import { S as ServerTransport } from '../server-dc261419.js';
7
7
  import '@sinclair/typebox';
8
- import '../client-c44d1c69.js';
8
+ import '../client-8ab60722.js';
9
9
  import '@opentelemetry/api';
10
10
  import '../types-3e5768ec.js';
11
11
 
@@ -54,6 +54,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
54
54
  maxCancelledStreamTombstonesPerSession?: number;
55
55
  }>): Server<Services>;
56
56
 
57
- var version = "0.205.1";
57
+ var version = "0.205.2";
58
58
 
59
59
  export { ParsedMetadata, version as RIVER_VERSION, Server, ServiceContext, createServer };
@@ -1,11 +1,11 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, a as AnyProcedure } from '../services-47b312aa.js';
2
- export { E as BaseErrorSchemaType, C as CANCEL_CODE, G as Client, H as Err, L as ErrResult, B as INVALID_REQUEST_CODE, O as Ok, M as OkResult, p as PayloadType, f as ProcErrors, P as ProcHandler, c as ProcInit, d as ProcRequest, e as ProcResponse, g as ProcType, v as Procedure, w as ProcedureErrorSchemaType, q as ProcedureMap, R as RPCProcedure, u as Readable, D as ReaderErrorSchema, T as ResponseData, K as Result, Q as ResultUnwrapErr, N as ResultUnwrapOk, k as SerializedProcedureSchema, o as SerializedProcedureSchemaProtocolv1, i as SerializedServerSchema, m as SerializedServerSchemaProtocolv1, j as SerializedServiceSchema, n as SerializedServiceSchemaProtocolv1, S as Service, b as ServiceConfiguration, h as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, y as UNCAUGHT_ERROR_CODE, z as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, F as createClient, x as flattenErrorType, s as serializeSchema, l as serializeSchemaV1Compat, J as unwrapOrThrow } from '../services-47b312aa.js';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, a as AnyProcedure } from '../services-036dcc97.js';
2
+ export { E as BaseErrorSchemaType, C as CANCEL_CODE, G as Client, H as Err, L as ErrResult, B as INVALID_REQUEST_CODE, O as Ok, M as OkResult, p as PayloadType, f as ProcErrors, P as ProcHandler, c as ProcInit, d as ProcRequest, e as ProcResponse, g as ProcType, v as Procedure, w as ProcedureErrorSchemaType, q as ProcedureMap, R as RPCProcedure, u as Readable, D as ReaderErrorSchema, T as ResponseData, K as Result, Q as ResultUnwrapErr, N as ResultUnwrapOk, k as SerializedProcedureSchema, o as SerializedProcedureSchemaProtocolv1, i as SerializedServerSchema, m as SerializedServerSchemaProtocolv1, j as SerializedServiceSchema, n as SerializedServiceSchemaProtocolv1, S as Service, b as ServiceConfiguration, h as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, y as UNCAUGHT_ERROR_CODE, z as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, F as createClient, x as flattenErrorType, s as serializeSchema, l as serializeSchemaV1Compat, J as unwrapOrThrow } from '../services-036dcc97.js';
3
3
  import { c as TransportClientId, b as OpaqueTransportMessage } from '../message-865bba35.js';
4
- import { q as ParsedMetadata, C as Connection, r as ServerHandshakeOptions, s as ServiceContext } from '../context-ebf88958.js';
5
- export { t as ProcedureHandlerContext, u as createClientHandshakeOptions, v as createServerHandshakeOptions } from '../context-ebf88958.js';
6
- import { S as ServerTransport } from '../server-b169b234.js';
4
+ import { q as ParsedMetadata, C as Connection, r as ServerHandshakeOptions, s as ServiceContext } from '../context-2c4bb66b.js';
5
+ export { t as ProcedureHandlerContext, u as createClientHandshakeOptions, v as createServerHandshakeOptions } from '../context-2c4bb66b.js';
6
+ import { S as ServerTransport } from '../server-dc261419.js';
7
7
  import '@sinclair/typebox';
8
- import '../client-c44d1c69.js';
8
+ import '../client-8ab60722.js';
9
9
  import '@opentelemetry/api';
10
10
  import '../types-3e5768ec.js';
11
11
 
@@ -54,6 +54,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
54
54
  maxCancelledStreamTombstonesPerSession?: number;
55
55
  }>): Server<Services>;
56
56
 
57
- var version = "0.205.1";
57
+ var version = "0.205.2";
58
58
 
59
59
  export { ParsedMetadata, version as RIVER_VERSION, Server, ServiceContext, createServer };
@@ -17,7 +17,7 @@ import {
17
17
  serializeSchemaV1Compat,
18
18
  unwrapOrThrow,
19
19
  version
20
- } from "../chunk-HNBYBRJ7.js";
20
+ } from "../chunk-BYA34LH3.js";
21
21
  export {
22
22
  CANCEL_CODE,
23
23
  Err,
@@ -1,4 +1,4 @@
1
- import { C as Connection, w as CommonSession, d as SessionState, x as CommonSessionProps, T as Transport, y as ServerTransportOptions, r as ServerHandshakeOptions, q as ParsedMetadata, z as ServerSession, c as ProvidedServerTransportOptions, D as DeleteSessionOptions } from './context-ebf88958.js';
1
+ import { C as Connection, w as CommonSession, d as SessionState, x as CommonSessionProps, T as Transport, y as ServerTransportOptions, r as ServerHandshakeOptions, q as ParsedMetadata, z as ServerSession, c as ProvidedServerTransportOptions, D as DeleteSessionOptions } from './context-2c4bb66b.js';
2
2
  import { P as ProtocolVersion, b as OpaqueTransportMessage, e as Tags, a as TransportMessage, H as HandshakeErrorResponseCodes, c as TransportClientId } from './message-865bba35.js';
3
3
  import { Static } from '@sinclair/typebox';
4
4
 
@@ -1,8 +1,8 @@
1
1
  import * as _sinclair_typebox from '@sinclair/typebox';
2
2
  import { TObject, TString, TSchema, TUnion, TLiteral, TNever, Static } from '@sinclair/typebox';
3
- import { C as Connection, n as ClientHandshakeOptions, t as ProcedureHandlerContext, s as ServiceContext } from './context-ebf88958.js';
3
+ import { C as Connection, n as ClientHandshakeOptions, t as ProcedureHandlerContext, s as ServiceContext } from './context-2c4bb66b.js';
4
4
  import { c as TransportClientId } from './message-865bba35.js';
5
- import { C as ClientTransport } from './client-c44d1c69.js';
5
+ import { C as ClientTransport } from './client-8ab60722.js';
6
6
 
7
7
  /**
8
8
  * {@link UNCAUGHT_ERROR_CODE} is the code that is used when an error is thrown
@@ -380,13 +380,27 @@ var IdentifiedSession = class extends CommonSession {
380
380
  * Index of the message we will send next (excluding handshake)
381
381
  */
382
382
  seq;
383
+ /**
384
+ * Last seq we sent over the wire this session (excluding handshake) and retransmissions
385
+ */
386
+ seqSent;
383
387
  /**
384
388
  * Number of unique messages we've received this session (excluding handshake)
385
389
  */
386
390
  ack;
387
391
  sendBuffer;
388
392
  constructor(props) {
389
- const { id, to, seq, ack, sendBuffer, telemetry, log, protocolVersion } = props;
393
+ const {
394
+ id,
395
+ to,
396
+ seq,
397
+ ack,
398
+ sendBuffer,
399
+ telemetry,
400
+ log,
401
+ protocolVersion,
402
+ seqSent: messagesSent
403
+ } = props;
390
404
  super(props);
391
405
  this.id = id;
392
406
  this.to = to;
@@ -396,6 +410,7 @@ var IdentifiedSession = class extends CommonSession {
396
410
  this.telemetry = telemetry;
397
411
  this.log = log;
398
412
  this.protocolVersion = protocolVersion;
413
+ this.seqSent = messagesSent;
399
414
  }
400
415
  get loggingMetadata() {
401
416
  const metadata = {
@@ -542,7 +557,7 @@ function coerceErrorString(err) {
542
557
  }
543
558
 
544
559
  // package.json
545
- var version = "0.205.1";
560
+ var version = "0.205.2";
546
561
 
547
562
  // tracing/index.ts
548
563
  function getPropagationContext(ctx) {
@@ -706,10 +721,23 @@ var SessionConnected = class extends IdentifiedSession {
706
721
  this.ack = seq + 1;
707
722
  this.heartbeatMisses = 0;
708
723
  }
724
+ assertSendOrdering(constructedMsg) {
725
+ if (constructedMsg.seq > this.seqSent + 1) {
726
+ const msg = `invariant violation: would have sent out of order msg (seq: ${constructedMsg.seq}, expected: ${this.seqSent} + 1)`;
727
+ this.log?.error(msg, {
728
+ ...this.loggingMetadata,
729
+ transportMessage: constructedMsg,
730
+ tags: ["invariant-violation"]
731
+ });
732
+ throw new Error(msg);
733
+ }
734
+ }
709
735
  send(msg) {
710
736
  const constructedMsg = this.constructMsg(msg);
737
+ this.assertSendOrdering(constructedMsg);
711
738
  this.sendBuffer.push(constructedMsg);
712
739
  this.conn.send(this.options.codec.toBuffer(constructedMsg));
740
+ this.seqSent = constructedMsg.seq;
713
741
  return constructedMsg.id;
714
742
  }
715
743
  constructor(props) {
@@ -725,7 +753,9 @@ var SessionConnected = class extends IdentifiedSession {
725
753
  this.loggingMetadata
726
754
  );
727
755
  for (const msg of this.sendBuffer) {
756
+ this.assertSendOrdering(msg);
728
757
  this.conn.send(this.options.codec.toBuffer(msg));
758
+ this.seqSent = msg.seq;
729
759
  }
730
760
  }
731
761
  this.isActivelyHeartbeating = false;
@@ -791,7 +821,7 @@ var SessionConnected = class extends IdentifiedSession {
791
821
  );
792
822
  } else {
793
823
  const reason = `received out-of-order msg, closing connection (got seq: ${parsedMsg.seq}, wanted seq: ${this.ack})`;
794
- this.log?.warn(reason, {
824
+ this.log?.error(reason, {
795
825
  ...this.loggingMetadata,
796
826
  transportMessage: parsedMsg,
797
827
  tags: ["invariant-violation"]
@@ -869,6 +899,7 @@ function inheritSharedSession(session) {
869
899
  to: session.to,
870
900
  seq: session.seq,
871
901
  ack: session.ack,
902
+ seqSent: session.seqSent,
872
903
  sendBuffer: session.sendBuffer,
873
904
  telemetry: session.telemetry,
874
905
  options: session.options,
@@ -896,6 +927,7 @@ var SessionStateGraph = {
896
927
  to,
897
928
  seq: 0,
898
929
  ack: 0,
930
+ seqSent: 0,
899
931
  graceExpiryTime: Date.now() + options.sessionDisconnectGraceMs,
900
932
  sendBuffer,
901
933
  telemetry,
@@ -1018,6 +1050,7 @@ var SessionStateGraph = {
1018
1050
  to,
1019
1051
  seq: 0,
1020
1052
  ack: 0,
1053
+ seqSent: 0,
1021
1054
  sendBuffer: [],
1022
1055
  telemetry: createSessionTelemetryInfo(
1023
1056
  pendingSession.tracer,
@@ -1448,7 +1481,7 @@ var Transport = class {
1448
1481
  });
1449
1482
  this.eventDispatcher.dispatchEvent("sessionTransition", {
1450
1483
  state: session.state,
1451
- session
1484
+ id: session.id
1452
1485
  });
1453
1486
  }
1454
1487
  updateSession(session) {
@@ -1472,7 +1505,7 @@ var Transport = class {
1472
1505
  this.sessions.set(session.to, session);
1473
1506
  this.eventDispatcher.dispatchEvent("sessionTransition", {
1474
1507
  state: session.state,
1475
- session
1508
+ id: session.id
1476
1509
  });
1477
1510
  }
1478
1511
  deleteSession(session, options) {
@@ -2259,8 +2292,8 @@ var ServerTransport = class extends Transport {
2259
2292
  }
2260
2293
  );
2261
2294
  oldSession = noConnectionSession;
2295
+ this.updateSession(oldSession);
2262
2296
  }
2263
- this.updateSession(oldSession);
2264
2297
  } else if (oldSession) {
2265
2298
  connectCase = "hard reconnection";
2266
2299
  this.log?.info(
@@ -2449,12 +2482,13 @@ var InMemoryConnection = class extends Connection {
2449
2482
  constructor(pipe) {
2450
2483
  super();
2451
2484
  this.conn = pipe;
2485
+ this.conn.allowHalfOpen = false;
2452
2486
  this.conn.on("data", (data) => {
2453
2487
  for (const cb of this.dataListeners) {
2454
2488
  cb(data);
2455
2489
  }
2456
2490
  });
2457
- this.conn.on("end", () => {
2491
+ this.conn.on("close", () => {
2458
2492
  for (const cb of this.closeListeners) {
2459
2493
  cb();
2460
2494
  }
@@ -2474,6 +2508,7 @@ var InMemoryConnection = class extends Connection {
2474
2508
  close() {
2475
2509
  setImmediate(() => {
2476
2510
  this.conn.end();
2511
+ this.conn.emit("close");
2477
2512
  });
2478
2513
  }
2479
2514
  };
@@ -2539,6 +2574,7 @@ function createMockTransportNetwork(opts) {
2539
2574
  simulatePhantomDisconnect() {
2540
2575
  for (const conn of Object.values(connections.get())) {
2541
2576
  conn.serverToClient.pause();
2577
+ conn.clientToServer.pause();
2542
2578
  }
2543
2579
  },
2544
2580
  async restartServer() {