@replit/river 0.24.3 → 0.25.1

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 (63) hide show
  1. package/dist/{chunk-XKHLA5MP.js → chunk-5CNNIOAO.js} +4 -4
  2. package/dist/{chunk-FKBXIWWN.js → chunk-D5O3ERJU.js} +3 -3
  3. package/dist/{chunk-EHXKU4TW.js → chunk-MBMEJIPU.js} +2 -2
  4. package/dist/{chunk-W3CY6PNC.js → chunk-PCBPPTXH.js} +28 -23
  5. package/dist/chunk-PCBPPTXH.js.map +1 -0
  6. package/dist/{chunk-LSHUPI6U.js → chunk-SGSRNAWJ.js} +41 -18
  7. package/dist/{chunk-LSHUPI6U.js.map → chunk-SGSRNAWJ.js.map} +1 -1
  8. package/dist/{chunk-DZNP3EI5.js → chunk-SZ5NBBX7.js} +2 -2
  9. package/dist/{chunk-DZNP3EI5.js.map → chunk-SZ5NBBX7.js.map} +1 -1
  10. package/dist/{chunk-KVLCQ24J.js → chunk-YM5Y4NAT.js} +34 -13
  11. package/dist/chunk-YM5Y4NAT.js.map +1 -0
  12. package/dist/{client-2ba72e89.d.ts → client-1321630c.d.ts} +1 -1
  13. package/dist/{connection-55cba970.d.ts → connection-bd907ca6.d.ts} +1 -1
  14. package/dist/{handshake-0b88e8fc.d.ts → handshake-3772d7ca.d.ts} +4 -2
  15. package/dist/router/index.cjs +40 -17
  16. package/dist/router/index.cjs.map +1 -1
  17. package/dist/router/index.d.cts +7 -7
  18. package/dist/router/index.d.ts +7 -7
  19. package/dist/router/index.js +2 -2
  20. package/dist/{server-732e7014.d.ts → server-f0fd2b98.d.ts} +1 -1
  21. package/dist/{services-adfd0bc3.d.ts → services-8d14ae16.d.ts} +2 -2
  22. package/dist/transport/impls/ws/client.cjs +33 -12
  23. package/dist/transport/impls/ws/client.cjs.map +1 -1
  24. package/dist/transport/impls/ws/client.d.cts +3 -3
  25. package/dist/transport/impls/ws/client.d.ts +3 -3
  26. package/dist/transport/impls/ws/client.js +7 -7
  27. package/dist/transport/impls/ws/server.cjs +57 -31
  28. package/dist/transport/impls/ws/server.cjs.map +1 -1
  29. package/dist/transport/impls/ws/server.d.cts +3 -3
  30. package/dist/transport/impls/ws/server.d.ts +3 -3
  31. package/dist/transport/impls/ws/server.js +5 -5
  32. package/dist/transport/index.cjs +57 -31
  33. package/dist/transport/index.cjs.map +1 -1
  34. package/dist/transport/index.d.cts +3 -3
  35. package/dist/transport/index.d.ts +3 -3
  36. package/dist/transport/index.js +7 -7
  37. package/dist/util/testHelpers.cjs +33 -27
  38. package/dist/util/testHelpers.cjs.map +1 -1
  39. package/dist/util/testHelpers.d.cts +4 -7
  40. package/dist/util/testHelpers.d.ts +4 -7
  41. package/dist/util/testHelpers.js +3 -14
  42. package/dist/util/testHelpers.js.map +1 -1
  43. package/package.json +13 -14
  44. package/dist/chunk-KVLCQ24J.js.map +0 -1
  45. package/dist/chunk-TDFWZIXR.js +0 -106
  46. package/dist/chunk-TDFWZIXR.js.map +0 -1
  47. package/dist/chunk-W3CY6PNC.js.map +0 -1
  48. package/dist/connection-c6db05d9.d.ts +0 -31
  49. package/dist/transport/impls/uds/client.cjs +0 -1684
  50. package/dist/transport/impls/uds/client.cjs.map +0 -1
  51. package/dist/transport/impls/uds/client.d.cts +0 -18
  52. package/dist/transport/impls/uds/client.d.ts +0 -18
  53. package/dist/transport/impls/uds/client.js +0 -38
  54. package/dist/transport/impls/uds/client.js.map +0 -1
  55. package/dist/transport/impls/uds/server.cjs +0 -1650
  56. package/dist/transport/impls/uds/server.cjs.map +0 -1
  57. package/dist/transport/impls/uds/server.d.cts +0 -19
  58. package/dist/transport/impls/uds/server.d.ts +0 -19
  59. package/dist/transport/impls/uds/server.js +0 -33
  60. package/dist/transport/impls/uds/server.js.map +0 -1
  61. /package/dist/{chunk-XKHLA5MP.js.map → chunk-5CNNIOAO.js.map} +0 -0
  62. /package/dist/{chunk-FKBXIWWN.js.map → chunk-D5O3ERJU.js.map} +0 -0
  63. /package/dist/{chunk-EHXKU4TW.js.map → chunk-MBMEJIPU.js.map} +0 -0
@@ -1,6 +1,6 @@
1
- export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../handshake-0b88e8fc.js';
2
- export { C as ClientTransport } from '../client-2ba72e89.js';
3
- export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-732e7014.js';
1
+ export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../handshake-3772d7ca.js';
2
+ export { C as ClientTransport } from '../client-1321630c.js';
3
+ export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-f0fd2b98.js';
4
4
  export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-e6c560fd.js';
5
5
  import '@sinclair/typebox';
6
6
  import '../types-3e5768ec.js';
@@ -1,6 +1,6 @@
1
- export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../handshake-0b88e8fc.js';
2
- export { C as ClientTransport } from '../client-2ba72e89.js';
3
- export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-732e7014.js';
1
+ export { b as ClientTransportOptions, C as Connection, j as EventHandler, E as EventMap, i as EventTypes, k as ProtocolError, l as ProtocolErrorType, c as ServerTransportOptions, S as Session, h as SessionConnected, f as SessionConnecting, g as SessionHandshaking, e as SessionNoConnection, d as SessionState, T as Transport, P as TransportOptions, a as TransportStatus } from '../handshake-3772d7ca.js';
2
+ export { C as ClientTransport } from '../client-1321630c.js';
3
+ export { S as ServerTransport, a as SessionWaitingForHandshake } from '../server-f0fd2b98.js';
4
4
  export { b as OpaqueTransportMessage, O as OpaqueTransportMessageSchema, c as TransportClientId, a as TransportMessage, T as TransportMessageSchema, d as isStreamClose, i as isStreamOpen } from '../message-e6c560fd.js';
5
5
  import '@sinclair/typebox';
6
6
  import '../types-3e5768ec.js';
@@ -1,22 +1,22 @@
1
- import {
2
- ServerTransport
3
- } from "../chunk-W3CY6PNC.js";
4
1
  import {
5
2
  ClientTransport
6
- } from "../chunk-XKHLA5MP.js";
3
+ } from "../chunk-5CNNIOAO.js";
4
+ import {
5
+ ServerTransport
6
+ } from "../chunk-PCBPPTXH.js";
7
7
  import {
8
8
  Connection,
9
9
  ProtocolError,
10
10
  Transport
11
- } from "../chunk-FKBXIWWN.js";
11
+ } from "../chunk-D5O3ERJU.js";
12
12
  import "../chunk-TAH2GVTJ.js";
13
13
  import {
14
14
  SessionState
15
- } from "../chunk-KVLCQ24J.js";
15
+ } from "../chunk-YM5Y4NAT.js";
16
16
  import {
17
17
  OpaqueTransportMessageSchema,
18
18
  TransportMessageSchema
19
- } from "../chunk-DZNP3EI5.js";
19
+ } from "../chunk-SZ5NBBX7.js";
20
20
  import "../chunk-4PVU7J25.js";
21
21
  export {
22
22
  ClientTransport,
@@ -40,10 +40,8 @@ __export(testHelpers_exports, {
40
40
  createWebSocketServer: () => createWebSocketServer,
41
41
  dummySession: () => dummySession,
42
42
  getTransportConnections: () => getTransportConnections,
43
- getUnixSocketPath: () => getUnixSocketPath,
44
43
  iterNext: () => iterNext,
45
44
  numberOfConnections: () => numberOfConnections,
46
- onUdsServeReady: () => onUdsServeReady,
47
45
  onWsServerReady: () => onWsServerReady,
48
46
  payloadToTransportMessage: () => payloadToTransportMessage,
49
47
  testingSessionOptions: () => testingSessionOptions,
@@ -452,7 +450,7 @@ function Err(error) {
452
450
  var import_api = require("@opentelemetry/api");
453
451
 
454
452
  // package.json
455
- var version = "0.24.3";
453
+ var version = "0.25.1";
456
454
 
457
455
  // tracing/index.ts
458
456
  function createSessionTelemetryInfo(sessionId, to, from, propagationCtx) {
@@ -482,9 +480,6 @@ function coerceErrorString(err) {
482
480
  return `[coerced to error] ${String(err)}`;
483
481
  }
484
482
 
485
- // util/testHelpers.ts
486
- var import_nanoid2 = require("nanoid");
487
-
488
483
  // codec/json.ts
489
484
  var encoder = new TextEncoder();
490
485
  var decoder = new TextDecoder();
@@ -865,15 +860,16 @@ var SessionConnected = class extends IdentifiedSession {
865
860
  state = "Connected" /* Connected */;
866
861
  conn;
867
862
  listeners;
868
- heartbeatHandle;
869
- heartbeatMisses = 0;
863
+ activeHeartbeatHandle;
864
+ activeHeartbeatMisses = 0;
865
+ passiveHeartbeatHandle;
870
866
  get isActivelyHeartbeating() {
871
- return this.heartbeatHandle !== void 0;
867
+ return this.activeHeartbeatHandle !== void 0;
872
868
  }
873
869
  updateBookkeeping(ack, seq) {
874
870
  this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
875
871
  this.ack = seq + 1;
876
- this.heartbeatMisses = 0;
872
+ this.activeHeartbeatMisses = 0;
877
873
  }
878
874
  send(msg) {
879
875
  const constructedMsg = this.constructMsg(msg);
@@ -899,8 +895,8 @@ var SessionConnected = class extends IdentifiedSession {
899
895
  }
900
896
  }
901
897
  startActiveHeartbeat() {
902
- this.heartbeatHandle = setInterval(() => {
903
- const misses = this.heartbeatMisses;
898
+ this.activeHeartbeatHandle = setInterval(() => {
899
+ const misses = this.activeHeartbeatMisses;
904
900
  const missDuration = misses * this.options.heartbeatIntervalMs;
905
901
  if (misses >= this.options.heartbeatsUntilDead) {
906
902
  this.log?.info(
@@ -909,15 +905,32 @@ var SessionConnected = class extends IdentifiedSession {
909
905
  );
910
906
  this.telemetry.span.addEvent("closing connection due to inactivity");
911
907
  this.conn.close();
912
- clearInterval(this.heartbeatHandle);
913
- this.heartbeatHandle = void 0;
908
+ clearInterval(this.activeHeartbeatHandle);
909
+ this.activeHeartbeatHandle = void 0;
914
910
  return;
915
911
  }
916
912
  this.sendHeartbeat();
917
- this.heartbeatMisses++;
913
+ this.activeHeartbeatMisses++;
918
914
  }, this.options.heartbeatIntervalMs);
919
915
  }
916
+ waitForNextHeartbeat() {
917
+ const duration = this.options.heartbeatsUntilDead * this.options.heartbeatIntervalMs;
918
+ if (this.passiveHeartbeatHandle) {
919
+ clearTimeout(this.passiveHeartbeatHandle);
920
+ this.passiveHeartbeatHandle = void 0;
921
+ }
922
+ this.passiveHeartbeatHandle = setTimeout(() => {
923
+ this.log?.info(
924
+ `closing connection to ${this.to} due to not receiving a heartbeat in the last ${duration}ms`,
925
+ this.loggingMetadata
926
+ );
927
+ this.telemetry.span.addEvent("closing connection due to inactivity");
928
+ this.conn.close();
929
+ this.passiveHeartbeatHandle = void 0;
930
+ }, duration);
931
+ }
920
932
  sendHeartbeat() {
933
+ this.log?.debug("sending heartbeat", this.loggingMetadata);
921
934
  this.send({
922
935
  streamId: "heartbeat",
923
936
  controlFlags: 1 /* AckBit */,
@@ -969,6 +982,7 @@ var SessionConnected = class extends IdentifiedSession {
969
982
  });
970
983
  if (!this.isActivelyHeartbeating) {
971
984
  this.sendHeartbeat();
985
+ this.waitForNextHeartbeat();
972
986
  }
973
987
  };
974
988
  _handleStateExit() {
@@ -976,8 +990,10 @@ var SessionConnected = class extends IdentifiedSession {
976
990
  this.conn.removeDataListener(this.onMessageData);
977
991
  this.conn.removeCloseListener(this.listeners.onConnectionClosed);
978
992
  this.conn.removeErrorListener(this.listeners.onConnectionErrored);
979
- clearInterval(this.heartbeatHandle);
980
- this.heartbeatHandle = void 0;
993
+ clearInterval(this.activeHeartbeatHandle);
994
+ clearTimeout(this.passiveHeartbeatHandle);
995
+ this.activeHeartbeatHandle = void 0;
996
+ this.passiveHeartbeatHandle = void 0;
981
997
  }
982
998
  _handleClose() {
983
999
  super._handleClose();
@@ -1185,11 +1201,6 @@ function onWsServerReady(server) {
1185
1201
  });
1186
1202
  });
1187
1203
  }
1188
- function onUdsServeReady(server, path) {
1189
- return new Promise((resolve) => {
1190
- server.listen(path, resolve);
1191
- });
1192
- }
1193
1204
  async function iterNext(iter) {
1194
1205
  return await iter.next().then((res) => res.value);
1195
1206
  }
@@ -1294,9 +1305,6 @@ function asClientUpload(state, proc, init, extendedContext, session = dummySessi
1294
1305
  return [input, result];
1295
1306
  }
1296
1307
  }
1297
- var getUnixSocketPath = () => {
1298
- return `/tmp/${(0, import_nanoid2.nanoid)()}.sock`;
1299
- };
1300
1308
  function getTransportConnections(transport) {
1301
1309
  const connections = [];
1302
1310
  for (const session of transport.sessions.values()) {
@@ -1326,10 +1334,8 @@ function closeAllConnections(transport) {
1326
1334
  createWebSocketServer,
1327
1335
  dummySession,
1328
1336
  getTransportConnections,
1329
- getUnixSocketPath,
1330
1337
  iterNext,
1331
1338
  numberOfConnections,
1332
- onUdsServeReady,
1333
1339
  onWsServerReady,
1334
1340
  payloadToTransportMessage,
1335
1341
  testingSessionOptions,