@replit/river 0.13.7 → 0.13.8

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 (34) hide show
  1. package/dist/{builder-533e1324.d.ts → builder-4bc0351d.d.ts} +1 -1
  2. package/dist/{chunk-7VOA27YR.js → chunk-65O4MCJZ.js} +1 -1
  3. package/dist/{chunk-KT6GLRGQ.js → chunk-L62HCTWX.js} +1 -1
  4. package/dist/{chunk-TSEEC3UM.js → chunk-ZIGZKCDJ.js} +22 -16
  5. package/dist/{connection-1f994b63.d.ts → connection-ba6a843a.d.ts} +1 -1
  6. package/dist/{connection-f46114a1.d.ts → connection-ede51542.d.ts} +1 -1
  7. package/dist/{index-2154021c.d.ts → index-56a709fc.d.ts} +2 -2
  8. package/dist/router/index.d.cts +3 -3
  9. package/dist/router/index.d.ts +3 -3
  10. package/dist/transport/impls/uds/client.cjs +22 -16
  11. package/dist/transport/impls/uds/client.d.cts +2 -2
  12. package/dist/transport/impls/uds/client.d.ts +2 -2
  13. package/dist/transport/impls/uds/client.js +2 -2
  14. package/dist/transport/impls/uds/server.cjs +19 -16
  15. package/dist/transport/impls/uds/server.d.cts +2 -2
  16. package/dist/transport/impls/uds/server.d.ts +2 -2
  17. package/dist/transport/impls/uds/server.js +2 -2
  18. package/dist/transport/impls/ws/client.cjs +22 -16
  19. package/dist/transport/impls/ws/client.d.cts +2 -2
  20. package/dist/transport/impls/ws/client.d.ts +2 -2
  21. package/dist/transport/impls/ws/client.js +2 -2
  22. package/dist/transport/impls/ws/server.cjs +19 -16
  23. package/dist/transport/impls/ws/server.d.cts +2 -2
  24. package/dist/transport/impls/ws/server.d.ts +2 -2
  25. package/dist/transport/impls/ws/server.js +2 -2
  26. package/dist/transport/index.cjs +22 -16
  27. package/dist/transport/index.d.cts +1 -1
  28. package/dist/transport/index.d.ts +1 -1
  29. package/dist/transport/index.js +1 -1
  30. package/dist/util/testHelpers.cjs +19 -16
  31. package/dist/util/testHelpers.d.cts +2 -2
  32. package/dist/util/testHelpers.d.ts +2 -2
  33. package/dist/util/testHelpers.js +1 -1
  34. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { TObject, TUnion, TString, TSchema, TNever, TLiteral, Static } from '@sinclair/typebox';
2
2
  import { Pushable } from 'it-pushable';
3
- import { b as TransportClientId, d as Session, C as Connection } from './index-2154021c.js';
3
+ import { b as TransportClientId, d as Session, C as Connection } from './index-56a709fc.js';
4
4
 
5
5
  /**
6
6
  * The context for services/procedures. This is used only on
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Connection
3
- } from "./chunk-TSEEC3UM.js";
3
+ } from "./chunk-ZIGZKCDJ.js";
4
4
 
5
5
  // transport/transforms/messageFraming.ts
6
6
  import { Transform } from "node:stream";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Connection
3
- } from "./chunk-TSEEC3UM.js";
3
+ } from "./chunk-ZIGZKCDJ.js";
4
4
 
5
5
  // transport/impls/ws/connection.ts
6
6
  var WebSocketConnection = class extends Connection {
@@ -121,8 +121,8 @@ var Session = class {
121
121
  * @param addToSendBuff Whether to add the message to the send buffer for retry.
122
122
  * @returns The full transport ID of the message that was attempted to be sent.
123
123
  */
124
- send(msg, addToSendBuff = true) {
125
- const fullMsg = this.constructMsg(msg, addToSendBuff);
124
+ send(msg) {
125
+ const fullMsg = this.constructMsg(msg);
126
126
  log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
127
127
  if (this.connection) {
128
128
  const ok = this.connection.send(this.codec.toBuffer(fullMsg));
@@ -148,16 +148,21 @@ var Session = class {
148
148
  }
149
149
  return;
150
150
  }
151
- this.send(
152
- {
153
- streamId: "heartbeat",
154
- controlFlags: 1 /* AckBit */,
155
- payload: {
156
- type: "ACK"
157
- }
158
- },
159
- false
160
- );
151
+ if (!this.connection)
152
+ return;
153
+ const heartbeatBuff = {
154
+ id: unsafeId(),
155
+ to: this.to,
156
+ from: this.from,
157
+ seq: this.seq,
158
+ ack: this.ack,
159
+ streamId: "heartbeat",
160
+ controlFlags: 1 /* AckBit */,
161
+ payload: {
162
+ type: "ACK"
163
+ }
164
+ };
165
+ this.connection.send(this.codec.toBuffer(heartbeatBuff));
161
166
  this.heartbeatMisses++;
162
167
  }
163
168
  resetBufferedMessages() {
@@ -230,7 +235,7 @@ var Session = class {
230
235
  get nextExpectedSeq() {
231
236
  return this.ack;
232
237
  }
233
- constructMsg(partialMsg, addToSendBuff = true) {
238
+ constructMsg(partialMsg) {
234
239
  const msg = {
235
240
  ...partialMsg,
236
241
  id: unsafeId(),
@@ -240,9 +245,7 @@ var Session = class {
240
245
  ack: this.ack
241
246
  };
242
247
  this.seq++;
243
- if (addToSendBuff) {
244
- this.sendBuffer.push(msg);
245
- }
248
+ this.sendBuffer.push(msg);
246
249
  return msg;
247
250
  }
248
251
  inspectSendBuffer() {
@@ -567,6 +570,9 @@ var ClientTransport = class extends Transport {
567
570
  if (session) {
568
571
  this.onDisconnect(conn, session);
569
572
  }
573
+ log?.info(
574
+ `${this.clientId} -- connection (id: ${conn.debugId}) to ${to} disconnected`
575
+ );
570
576
  void this.connect(to);
571
577
  });
572
578
  conn.addErrorListener((err) => {
@@ -1,4 +1,4 @@
1
- import { C as Connection } from './index-2154021c.js';
1
+ import { C as Connection } from './index-56a709fc.js';
2
2
  import { Socket } from 'node:net';
3
3
  import stream, { Transform, TransformCallback, TransformOptions } from 'node:stream';
4
4
 
@@ -1,5 +1,5 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { C as Connection } from './index-2154021c.js';
2
+ import { C as Connection } from './index-56a709fc.js';
3
3
 
4
4
  declare class WebSocketConnection extends Connection {
5
5
  ws: WebSocket;
@@ -188,7 +188,7 @@ declare class Session<ConnType extends Connection> {
188
188
  * @param addToSendBuff Whether to add the message to the send buffer for retry.
189
189
  * @returns The full transport ID of the message that was attempted to be sent.
190
190
  */
191
- send(msg: PartialTransportMessage, addToSendBuff?: boolean): string;
191
+ send(msg: PartialTransportMessage): string;
192
192
  sendHeartbeat(): void;
193
193
  resetBufferedMessages(): void;
194
194
  sendBufferedMessages(): void;
@@ -200,7 +200,7 @@ declare class Session<ConnType extends Connection> {
200
200
  close(): void;
201
201
  get connected(): boolean;
202
202
  get nextExpectedSeq(): number;
203
- constructMsg<Payload extends Record<string, unknown>>(partialMsg: PartialTransportMessage<Payload>, addToSendBuff?: boolean): TransportMessage<Payload>;
203
+ constructMsg<Payload extends Record<string, unknown>>(partialMsg: PartialTransportMessage<Payload>): TransportMessage<Payload>;
204
204
  inspectSendBuffer(): ReadonlyArray<OpaqueTransportMessage>;
205
205
  }
206
206
 
@@ -1,6 +1,6 @@
1
- import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-533e1324.js';
2
- export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-533e1324.js';
3
- import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-2154021c.js';
1
+ import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-4bc0351d.js';
2
+ export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-4bc0351d.js';
3
+ import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-56a709fc.js';
4
4
  import { Pushable } from 'it-pushable';
5
5
  import { Static } from '@sinclair/typebox';
6
6
  import '../types-3e5768ec.js';
@@ -1,6 +1,6 @@
1
- import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-533e1324.js';
2
- export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-533e1324.js';
3
- import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-2154021c.js';
1
+ import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-4bc0351d.js';
2
+ export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-4bc0351d.js';
3
+ import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-56a709fc.js';
4
4
  import { Pushable } from 'it-pushable';
5
5
  import { Static } from '@sinclair/typebox';
6
6
  import '../types-3e5768ec.js';
@@ -229,8 +229,8 @@ var Session = class {
229
229
  * @param addToSendBuff Whether to add the message to the send buffer for retry.
230
230
  * @returns The full transport ID of the message that was attempted to be sent.
231
231
  */
232
- send(msg, addToSendBuff = true) {
233
- const fullMsg = this.constructMsg(msg, addToSendBuff);
232
+ send(msg) {
233
+ const fullMsg = this.constructMsg(msg);
234
234
  log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
235
235
  if (this.connection) {
236
236
  const ok = this.connection.send(this.codec.toBuffer(fullMsg));
@@ -256,16 +256,21 @@ var Session = class {
256
256
  }
257
257
  return;
258
258
  }
259
- this.send(
260
- {
261
- streamId: "heartbeat",
262
- controlFlags: 1 /* AckBit */,
263
- payload: {
264
- type: "ACK"
265
- }
266
- },
267
- false
268
- );
259
+ if (!this.connection)
260
+ return;
261
+ const heartbeatBuff = {
262
+ id: unsafeId(),
263
+ to: this.to,
264
+ from: this.from,
265
+ seq: this.seq,
266
+ ack: this.ack,
267
+ streamId: "heartbeat",
268
+ controlFlags: 1 /* AckBit */,
269
+ payload: {
270
+ type: "ACK"
271
+ }
272
+ };
273
+ this.connection.send(this.codec.toBuffer(heartbeatBuff));
269
274
  this.heartbeatMisses++;
270
275
  }
271
276
  resetBufferedMessages() {
@@ -338,7 +343,7 @@ var Session = class {
338
343
  get nextExpectedSeq() {
339
344
  return this.ack;
340
345
  }
341
- constructMsg(partialMsg, addToSendBuff = true) {
346
+ constructMsg(partialMsg) {
342
347
  const msg = {
343
348
  ...partialMsg,
344
349
  id: unsafeId(),
@@ -348,9 +353,7 @@ var Session = class {
348
353
  ack: this.ack
349
354
  };
350
355
  this.seq++;
351
- if (addToSendBuff) {
352
- this.sendBuffer.push(msg);
353
- }
356
+ this.sendBuffer.push(msg);
354
357
  return msg;
355
358
  }
356
359
  inspectSendBuffer() {
@@ -808,6 +811,9 @@ var ClientTransport = class extends Transport {
808
811
  if (session) {
809
812
  this.onDisconnect(conn, session);
810
813
  }
814
+ log?.info(
815
+ `${this.clientId} -- connection (id: ${conn.debugId}) to ${to} disconnected`
816
+ );
811
817
  void this.connect(to);
812
818
  });
813
819
  conn.addErrorListener((err) => {
@@ -1,5 +1,5 @@
1
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
2
- import { U as UdsConnection } from '../../../connection-1f994b63.js';
1
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-56a709fc.js';
2
+ import { U as UdsConnection } from '../../../connection-ba6a843a.js';
3
3
  import '../../../types-3e5768ec.js';
4
4
  import '@sinclair/typebox';
5
5
  import 'node:net';
@@ -1,5 +1,5 @@
1
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
2
- import { U as UdsConnection } from '../../../connection-1f994b63.js';
1
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-56a709fc.js';
2
+ import { U as UdsConnection } from '../../../connection-ba6a843a.js';
3
3
  import '../../../types-3e5768ec.js';
4
4
  import '@sinclair/typebox';
5
5
  import 'node:net';
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  UdsConnection
3
- } from "../../../chunk-7VOA27YR.js";
3
+ } from "../../../chunk-65O4MCJZ.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-TSEEC3UM.js";
6
+ } from "../../../chunk-ZIGZKCDJ.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import {
9
9
  log
@@ -267,8 +267,8 @@ var Session = class {
267
267
  * @param addToSendBuff Whether to add the message to the send buffer for retry.
268
268
  * @returns The full transport ID of the message that was attempted to be sent.
269
269
  */
270
- send(msg, addToSendBuff = true) {
271
- const fullMsg = this.constructMsg(msg, addToSendBuff);
270
+ send(msg) {
271
+ const fullMsg = this.constructMsg(msg);
272
272
  log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
273
273
  if (this.connection) {
274
274
  const ok = this.connection.send(this.codec.toBuffer(fullMsg));
@@ -294,16 +294,21 @@ var Session = class {
294
294
  }
295
295
  return;
296
296
  }
297
- this.send(
298
- {
299
- streamId: "heartbeat",
300
- controlFlags: 1 /* AckBit */,
301
- payload: {
302
- type: "ACK"
303
- }
304
- },
305
- false
306
- );
297
+ if (!this.connection)
298
+ return;
299
+ const heartbeatBuff = {
300
+ id: unsafeId(),
301
+ to: this.to,
302
+ from: this.from,
303
+ seq: this.seq,
304
+ ack: this.ack,
305
+ streamId: "heartbeat",
306
+ controlFlags: 1 /* AckBit */,
307
+ payload: {
308
+ type: "ACK"
309
+ }
310
+ };
311
+ this.connection.send(this.codec.toBuffer(heartbeatBuff));
307
312
  this.heartbeatMisses++;
308
313
  }
309
314
  resetBufferedMessages() {
@@ -376,7 +381,7 @@ var Session = class {
376
381
  get nextExpectedSeq() {
377
382
  return this.ack;
378
383
  }
379
- constructMsg(partialMsg, addToSendBuff = true) {
384
+ constructMsg(partialMsg) {
380
385
  const msg = {
381
386
  ...partialMsg,
382
387
  id: unsafeId(),
@@ -386,9 +391,7 @@ var Session = class {
386
391
  ack: this.ack
387
392
  };
388
393
  this.seq++;
389
- if (addToSendBuff) {
390
- this.sendBuffer.push(msg);
391
- }
394
+ this.sendBuffer.push(msg);
392
395
  return msg;
393
396
  }
394
397
  inspectSendBuffer() {
@@ -1,6 +1,6 @@
1
1
  import { Server, Socket } from 'node:net';
2
- import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
3
- import { U as UdsConnection } from '../../../connection-1f994b63.js';
2
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-56a709fc.js';
3
+ import { U as UdsConnection } from '../../../connection-ba6a843a.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
  import 'node:stream';
@@ -1,6 +1,6 @@
1
1
  import { Server, Socket } from 'node:net';
2
- import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
3
- import { U as UdsConnection } from '../../../connection-1f994b63.js';
2
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-56a709fc.js';
3
+ import { U as UdsConnection } from '../../../connection-ba6a843a.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
  import 'node:stream';
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  UdsConnection
3
- } from "../../../chunk-7VOA27YR.js";
3
+ } from "../../../chunk-65O4MCJZ.js";
4
4
  import {
5
5
  ServerTransport
6
- } from "../../../chunk-TSEEC3UM.js";
6
+ } from "../../../chunk-ZIGZKCDJ.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import {
9
9
  log
@@ -259,8 +259,8 @@ var Session = class {
259
259
  * @param addToSendBuff Whether to add the message to the send buffer for retry.
260
260
  * @returns The full transport ID of the message that was attempted to be sent.
261
261
  */
262
- send(msg, addToSendBuff = true) {
263
- const fullMsg = this.constructMsg(msg, addToSendBuff);
262
+ send(msg) {
263
+ const fullMsg = this.constructMsg(msg);
264
264
  log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
265
265
  if (this.connection) {
266
266
  const ok = this.connection.send(this.codec.toBuffer(fullMsg));
@@ -286,16 +286,21 @@ var Session = class {
286
286
  }
287
287
  return;
288
288
  }
289
- this.send(
290
- {
291
- streamId: "heartbeat",
292
- controlFlags: 1 /* AckBit */,
293
- payload: {
294
- type: "ACK"
295
- }
296
- },
297
- false
298
- );
289
+ if (!this.connection)
290
+ return;
291
+ const heartbeatBuff = {
292
+ id: unsafeId(),
293
+ to: this.to,
294
+ from: this.from,
295
+ seq: this.seq,
296
+ ack: this.ack,
297
+ streamId: "heartbeat",
298
+ controlFlags: 1 /* AckBit */,
299
+ payload: {
300
+ type: "ACK"
301
+ }
302
+ };
303
+ this.connection.send(this.codec.toBuffer(heartbeatBuff));
299
304
  this.heartbeatMisses++;
300
305
  }
301
306
  resetBufferedMessages() {
@@ -368,7 +373,7 @@ var Session = class {
368
373
  get nextExpectedSeq() {
369
374
  return this.ack;
370
375
  }
371
- constructMsg(partialMsg, addToSendBuff = true) {
376
+ constructMsg(partialMsg) {
372
377
  const msg = {
373
378
  ...partialMsg,
374
379
  id: unsafeId(),
@@ -378,9 +383,7 @@ var Session = class {
378
383
  ack: this.ack
379
384
  };
380
385
  this.seq++;
381
- if (addToSendBuff) {
382
- this.sendBuffer.push(msg);
383
- }
386
+ this.sendBuffer.push(msg);
384
387
  return msg;
385
388
  }
386
389
  inspectSendBuffer() {
@@ -714,6 +717,9 @@ var ClientTransport = class extends Transport {
714
717
  if (session) {
715
718
  this.onDisconnect(conn, session);
716
719
  }
720
+ log?.info(
721
+ `${this.clientId} -- connection (id: ${conn.debugId}) to ${to} disconnected`
722
+ );
717
723
  void this.connect(to);
718
724
  });
719
725
  conn.addErrorListener((err) => {
@@ -1,6 +1,6 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
3
- import { W as WebSocketConnection } from '../../../connection-f46114a1.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-56a709fc.js';
3
+ import { W as WebSocketConnection } from '../../../connection-ede51542.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
3
- import { W as WebSocketConnection } from '../../../connection-f46114a1.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-56a709fc.js';
3
+ import { W as WebSocketConnection } from '../../../connection-ede51542.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
 
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  WebSocketConnection
3
- } from "../../../chunk-KT6GLRGQ.js";
3
+ } from "../../../chunk-L62HCTWX.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-TSEEC3UM.js";
6
+ } from "../../../chunk-ZIGZKCDJ.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import {
9
9
  log
@@ -267,8 +267,8 @@ var Session = class {
267
267
  * @param addToSendBuff Whether to add the message to the send buffer for retry.
268
268
  * @returns The full transport ID of the message that was attempted to be sent.
269
269
  */
270
- send(msg, addToSendBuff = true) {
271
- const fullMsg = this.constructMsg(msg, addToSendBuff);
270
+ send(msg) {
271
+ const fullMsg = this.constructMsg(msg);
272
272
  log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
273
273
  if (this.connection) {
274
274
  const ok = this.connection.send(this.codec.toBuffer(fullMsg));
@@ -294,16 +294,21 @@ var Session = class {
294
294
  }
295
295
  return;
296
296
  }
297
- this.send(
298
- {
299
- streamId: "heartbeat",
300
- controlFlags: 1 /* AckBit */,
301
- payload: {
302
- type: "ACK"
303
- }
304
- },
305
- false
306
- );
297
+ if (!this.connection)
298
+ return;
299
+ const heartbeatBuff = {
300
+ id: unsafeId(),
301
+ to: this.to,
302
+ from: this.from,
303
+ seq: this.seq,
304
+ ack: this.ack,
305
+ streamId: "heartbeat",
306
+ controlFlags: 1 /* AckBit */,
307
+ payload: {
308
+ type: "ACK"
309
+ }
310
+ };
311
+ this.connection.send(this.codec.toBuffer(heartbeatBuff));
307
312
  this.heartbeatMisses++;
308
313
  }
309
314
  resetBufferedMessages() {
@@ -376,7 +381,7 @@ var Session = class {
376
381
  get nextExpectedSeq() {
377
382
  return this.ack;
378
383
  }
379
- constructMsg(partialMsg, addToSendBuff = true) {
384
+ constructMsg(partialMsg) {
380
385
  const msg = {
381
386
  ...partialMsg,
382
387
  id: unsafeId(),
@@ -386,9 +391,7 @@ var Session = class {
386
391
  ack: this.ack
387
392
  };
388
393
  this.seq++;
389
- if (addToSendBuff) {
390
- this.sendBuffer.push(msg);
391
- }
394
+ this.sendBuffer.push(msg);
392
395
  return msg;
393
396
  }
394
397
  inspectSendBuffer() {
@@ -1,7 +1,7 @@
1
- import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
1
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-56a709fc.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-f46114a1.js';
4
+ import { W as WebSocketConnection } from '../../../connection-ede51542.js';
5
5
  import '../../../types-3e5768ec.js';
6
6
  import '@sinclair/typebox';
7
7
 
@@ -1,7 +1,7 @@
1
- import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
1
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-56a709fc.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-f46114a1.js';
4
+ import { W as WebSocketConnection } from '../../../connection-ede51542.js';
5
5
  import '../../../types-3e5768ec.js';
6
6
  import '@sinclair/typebox';
7
7
 
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  WebSocketConnection
3
- } from "../../../chunk-KT6GLRGQ.js";
3
+ } from "../../../chunk-L62HCTWX.js";
4
4
  import {
5
5
  ServerTransport
6
- } from "../../../chunk-TSEEC3UM.js";
6
+ } from "../../../chunk-ZIGZKCDJ.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import "../../../chunk-H4BYJELI.js";
9
9
  import "../../../chunk-GZ7HCLLM.js";
@@ -289,8 +289,8 @@ var Session = class {
289
289
  * @param addToSendBuff Whether to add the message to the send buffer for retry.
290
290
  * @returns The full transport ID of the message that was attempted to be sent.
291
291
  */
292
- send(msg, addToSendBuff = true) {
293
- const fullMsg = this.constructMsg(msg, addToSendBuff);
292
+ send(msg) {
293
+ const fullMsg = this.constructMsg(msg);
294
294
  log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
295
295
  if (this.connection) {
296
296
  const ok = this.connection.send(this.codec.toBuffer(fullMsg));
@@ -316,16 +316,21 @@ var Session = class {
316
316
  }
317
317
  return;
318
318
  }
319
- this.send(
320
- {
321
- streamId: "heartbeat",
322
- controlFlags: 1 /* AckBit */,
323
- payload: {
324
- type: "ACK"
325
- }
326
- },
327
- false
328
- );
319
+ if (!this.connection)
320
+ return;
321
+ const heartbeatBuff = {
322
+ id: unsafeId(),
323
+ to: this.to,
324
+ from: this.from,
325
+ seq: this.seq,
326
+ ack: this.ack,
327
+ streamId: "heartbeat",
328
+ controlFlags: 1 /* AckBit */,
329
+ payload: {
330
+ type: "ACK"
331
+ }
332
+ };
333
+ this.connection.send(this.codec.toBuffer(heartbeatBuff));
329
334
  this.heartbeatMisses++;
330
335
  }
331
336
  resetBufferedMessages() {
@@ -398,7 +403,7 @@ var Session = class {
398
403
  get nextExpectedSeq() {
399
404
  return this.ack;
400
405
  }
401
- constructMsg(partialMsg, addToSendBuff = true) {
406
+ constructMsg(partialMsg) {
402
407
  const msg = {
403
408
  ...partialMsg,
404
409
  id: unsafeId(),
@@ -408,9 +413,7 @@ var Session = class {
408
413
  ack: this.ack
409
414
  };
410
415
  this.seq++;
411
- if (addToSendBuff) {
412
- this.sendBuffer.push(msg);
413
- }
416
+ this.sendBuffer.push(msg);
414
417
  return msg;
415
418
  }
416
419
  inspectSendBuffer() {
@@ -744,6 +747,9 @@ var ClientTransport = class extends Transport {
744
747
  if (session) {
745
748
  this.onDisconnect(conn, session);
746
749
  }
750
+ log?.info(
751
+ `${this.clientId} -- connection (id: ${conn.debugId}) to ${to} disconnected`
752
+ );
747
753
  void this.connect(to);
748
754
  });
749
755
  conn.addErrorListener((err) => {
@@ -1,3 +1,3 @@
1
- export { a as ClientTransport, C as Connection, l as EventHandler, E as EventMap, k as EventTypes, O as OpaqueTransportMessage, g as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, h as TransportMessage, f as TransportMessageSchema, c as TransportOptions, e as TransportStatus, j as isStreamClose, i as isStreamOpen } from '../index-2154021c.js';
1
+ export { a as ClientTransport, C as Connection, l as EventHandler, E as EventMap, k as EventTypes, O as OpaqueTransportMessage, g as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, h as TransportMessage, f as TransportMessageSchema, c as TransportOptions, e as TransportStatus, j as isStreamClose, i as isStreamOpen } from '../index-56a709fc.js';
2
2
  import '../types-3e5768ec.js';
3
3
  import '@sinclair/typebox';
@@ -1,3 +1,3 @@
1
- export { a as ClientTransport, C as Connection, l as EventHandler, E as EventMap, k as EventTypes, O as OpaqueTransportMessage, g as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, h as TransportMessage, f as TransportMessageSchema, c as TransportOptions, e as TransportStatus, j as isStreamClose, i as isStreamOpen } from '../index-2154021c.js';
1
+ export { a as ClientTransport, C as Connection, l as EventHandler, E as EventMap, k as EventTypes, O as OpaqueTransportMessage, g as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, h as TransportMessage, f as TransportMessageSchema, c as TransportOptions, e as TransportStatus, j as isStreamClose, i as isStreamOpen } from '../index-56a709fc.js';
2
2
  import '../types-3e5768ec.js';
3
3
  import '@sinclair/typebox';
@@ -5,7 +5,7 @@ import {
5
5
  ServerTransport,
6
6
  Session,
7
7
  Transport
8
- } from "../chunk-TSEEC3UM.js";
8
+ } from "../chunk-ZIGZKCDJ.js";
9
9
  import {
10
10
  OpaqueTransportMessageSchema,
11
11
  TransportMessageSchema
@@ -177,8 +177,8 @@ var Session = class {
177
177
  * @param addToSendBuff Whether to add the message to the send buffer for retry.
178
178
  * @returns The full transport ID of the message that was attempted to be sent.
179
179
  */
180
- send(msg, addToSendBuff = true) {
181
- const fullMsg = this.constructMsg(msg, addToSendBuff);
180
+ send(msg) {
181
+ const fullMsg = this.constructMsg(msg);
182
182
  log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
183
183
  if (this.connection) {
184
184
  const ok = this.connection.send(this.codec.toBuffer(fullMsg));
@@ -204,16 +204,21 @@ var Session = class {
204
204
  }
205
205
  return;
206
206
  }
207
- this.send(
208
- {
209
- streamId: "heartbeat",
210
- controlFlags: 1 /* AckBit */,
211
- payload: {
212
- type: "ACK"
213
- }
214
- },
215
- false
216
- );
207
+ if (!this.connection)
208
+ return;
209
+ const heartbeatBuff = {
210
+ id: unsafeId(),
211
+ to: this.to,
212
+ from: this.from,
213
+ seq: this.seq,
214
+ ack: this.ack,
215
+ streamId: "heartbeat",
216
+ controlFlags: 1 /* AckBit */,
217
+ payload: {
218
+ type: "ACK"
219
+ }
220
+ };
221
+ this.connection.send(this.codec.toBuffer(heartbeatBuff));
217
222
  this.heartbeatMisses++;
218
223
  }
219
224
  resetBufferedMessages() {
@@ -286,7 +291,7 @@ var Session = class {
286
291
  get nextExpectedSeq() {
287
292
  return this.ack;
288
293
  }
289
- constructMsg(partialMsg, addToSendBuff = true) {
294
+ constructMsg(partialMsg) {
290
295
  const msg = {
291
296
  ...partialMsg,
292
297
  id: unsafeId(),
@@ -296,9 +301,7 @@ var Session = class {
296
301
  ack: this.ack
297
302
  };
298
303
  this.seq++;
299
- if (addToSendBuff) {
300
- this.sendBuffer.push(msg);
301
- }
304
+ this.sendBuffer.push(msg);
302
305
  return msg;
303
306
  }
304
307
  inspectSendBuffer() {
@@ -1,8 +1,8 @@
1
1
  import * as it_pushable from 'it-pushable';
2
2
  import WebSocket from 'isomorphic-ws';
3
3
  import http from 'node:http';
4
- import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-2154021c.js';
5
- import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-533e1324.js';
4
+ import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-56a709fc.js';
5
+ import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-4bc0351d.js';
6
6
  import { Static } from '@sinclair/typebox';
7
7
  import net from 'node:net';
8
8
  import '../types-3e5768ec.js';
@@ -1,8 +1,8 @@
1
1
  import * as it_pushable from 'it-pushable';
2
2
  import WebSocket from 'isomorphic-ws';
3
3
  import http from 'node:http';
4
- import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-2154021c.js';
5
- import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-533e1324.js';
4
+ import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-56a709fc.js';
5
+ import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-4bc0351d.js';
6
6
  import { Static } from '@sinclair/typebox';
7
7
  import net from 'node:net';
8
8
  import '../types-3e5768ec.js';
@@ -6,7 +6,7 @@ import "../chunk-5IZ2UHWV.js";
6
6
  import {
7
7
  Session,
8
8
  defaultSessionOptions
9
- } from "../chunk-TSEEC3UM.js";
9
+ } from "../chunk-ZIGZKCDJ.js";
10
10
  import {
11
11
  coerceErrorString
12
12
  } from "../chunk-GFRAOY75.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@replit/river",
3
3
  "description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
4
- "version": "0.13.7",
4
+ "version": "0.13.8",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {