@replit/river 0.13.8 → 0.13.10

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 (37) hide show
  1. package/dist/{builder-4bc0351d.d.ts → builder-8c80cf47.d.ts} +1 -1
  2. package/dist/{chunk-65O4MCJZ.js → chunk-44GN4JUR.js} +1 -1
  3. package/dist/{chunk-ZIGZKCDJ.js → chunk-5ETR5EVH.js} +9 -15
  4. package/dist/{chunk-L62HCTWX.js → chunk-IPSTJ7NW.js} +1 -1
  5. package/dist/{chunk-E2CP4UWB.js → chunk-KUQ4OT4D.js} +3 -1
  6. package/dist/{connection-ede51542.d.ts → connection-88c9269b.d.ts} +1 -1
  7. package/dist/{connection-ba6a843a.d.ts → connection-ebd00fd5.d.ts} +1 -1
  8. package/dist/{index-56a709fc.d.ts → index-047087cb.d.ts} +2 -2
  9. package/dist/router/index.cjs +3 -1
  10. package/dist/router/index.d.cts +3 -3
  11. package/dist/router/index.d.ts +3 -3
  12. package/dist/router/index.js +1 -1
  13. package/dist/transport/impls/uds/client.cjs +9 -15
  14. package/dist/transport/impls/uds/client.d.cts +2 -2
  15. package/dist/transport/impls/uds/client.d.ts +2 -2
  16. package/dist/transport/impls/uds/client.js +2 -2
  17. package/dist/transport/impls/uds/server.cjs +4 -12
  18. package/dist/transport/impls/uds/server.d.cts +2 -2
  19. package/dist/transport/impls/uds/server.d.ts +2 -2
  20. package/dist/transport/impls/uds/server.js +2 -2
  21. package/dist/transport/impls/ws/client.cjs +9 -15
  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 +2 -2
  25. package/dist/transport/impls/ws/server.cjs +4 -12
  26. package/dist/transport/impls/ws/server.d.cts +2 -2
  27. package/dist/transport/impls/ws/server.d.ts +2 -2
  28. package/dist/transport/impls/ws/server.js +2 -2
  29. package/dist/transport/index.cjs +9 -15
  30. package/dist/transport/index.d.cts +1 -1
  31. package/dist/transport/index.d.ts +1 -1
  32. package/dist/transport/index.js +1 -1
  33. package/dist/util/testHelpers.cjs +4 -12
  34. package/dist/util/testHelpers.d.cts +2 -2
  35. package/dist/util/testHelpers.d.ts +2 -2
  36. package/dist/util/testHelpers.js +2 -2
  37. 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-56a709fc.js';
3
+ import { b as TransportClientId, d as Session, C as Connection } from './index-047087cb.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-ZIGZKCDJ.js";
3
+ } from "./chunk-5ETR5EVH.js";
4
4
 
5
5
  // transport/transforms/messageFraming.ts
6
6
  import { Transform } from "node:stream";
@@ -80,11 +80,11 @@ var Session = class {
80
80
  */
81
81
  debugId;
82
82
  /**
83
- * Number of messages we've sent along this session (excluding handshake)
83
+ * Number of messages we've sent along this session (excluding handshake and acks)
84
84
  */
85
85
  seq = 0;
86
86
  /**
87
- * Number of unique messages we've received this session (excluding handshake)
87
+ * Number of unique messages we've received this session (excluding handshake and acks)
88
88
  */
89
89
  ack = 0;
90
90
  /**
@@ -148,21 +148,13 @@ var Session = class {
148
148
  }
149
149
  return;
150
150
  }
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,
151
+ this.send({
159
152
  streamId: "heartbeat",
160
153
  controlFlags: 1 /* AckBit */,
161
154
  payload: {
162
155
  type: "ACK"
163
156
  }
164
- };
165
- this.connection.send(this.codec.toBuffer(heartbeatBuff));
157
+ });
166
158
  this.heartbeatMisses++;
167
159
  }
168
160
  resetBufferedMessages() {
@@ -620,12 +612,14 @@ var ClientTransport = class extends Transport {
620
612
  }
621
613
  let reconnectPromise = this.inflightConnectionPromises.get(to);
622
614
  if (!reconnectPromise) {
623
- reconnectPromise = this.createNewOutgoingConnection(to);
615
+ reconnectPromise = this.createNewOutgoingConnection(to).then((conn) => {
616
+ this.sendHandshake(to, conn);
617
+ return conn;
618
+ });
624
619
  this.inflightConnectionPromises.set(to, reconnectPromise);
625
620
  }
626
621
  try {
627
- const conn = await reconnectPromise;
628
- this.sendHandshake(to, conn);
622
+ await reconnectPromise;
629
623
  } catch (error) {
630
624
  const errStr = coerceErrorString(error);
631
625
  this.inflightConnectionPromises.delete(to);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Connection
3
- } from "./chunk-ZIGZKCDJ.js";
3
+ } from "./chunk-5ETR5EVH.js";
4
4
 
5
5
  // transport/impls/ws/connection.ts
6
6
  var WebSocketConnection = class extends Connection {
@@ -773,12 +773,14 @@ var RiverServer = class {
773
773
  log?.error(
774
774
  `${this.transport.clientId} -- can't create a new procedure stream from a message that doesn't have the stream open bit set`
775
775
  );
776
+ log?.debug(` -> ${JSON.stringify(message)}`);
776
777
  return;
777
778
  }
778
779
  if (!message.procedureName || !message.serviceName) {
779
780
  log?.warn(
780
781
  `${this.transport.clientId} -- missing procedure or service name in stream open message`
781
782
  );
783
+ log?.debug(` -> ${JSON.stringify(message)}`);
782
784
  return;
783
785
  }
784
786
  if (!(message.serviceName in this.services)) {
@@ -839,7 +841,7 @@ var RiverServer = class {
839
841
  const errorHandler = (err) => {
840
842
  const errorMsg = coerceErrorString(err);
841
843
  log?.error(
842
- `${this.transport.clientId} -- procedure ${message.serviceName}.${message.procedureName}:${message.streamId} threw an error: ${errorMsg}`
844
+ `${this.transport.clientId} -- procedure ${message.serviceName}.${message.procedureName}:${message.streamId} threw an uncaught error: ${errorMsg}`
843
845
  );
844
846
  outgoing.push(
845
847
  Err({
@@ -1,5 +1,5 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { C as Connection } from './index-56a709fc.js';
2
+ import { C as Connection } from './index-047087cb.js';
3
3
 
4
4
  declare class WebSocketConnection extends Connection {
5
5
  ws: WebSocket;
@@ -1,4 +1,4 @@
1
- import { C as Connection } from './index-56a709fc.js';
1
+ import { C as Connection } from './index-047087cb.js';
2
2
  import { Socket } from 'node:net';
3
3
  import stream, { Transform, TransformCallback, TransformOptions } from 'node:stream';
4
4
 
@@ -159,11 +159,11 @@ declare class Session<ConnType extends Connection> {
159
159
  */
160
160
  debugId: string;
161
161
  /**
162
- * Number of messages we've sent along this session (excluding handshake)
162
+ * Number of messages we've sent along this session (excluding handshake and acks)
163
163
  */
164
164
  private seq;
165
165
  /**
166
- * Number of unique messages we've received this session (excluding handshake)
166
+ * Number of unique messages we've received this session (excluding handshake and acks)
167
167
  */
168
168
  private ack;
169
169
  /**
@@ -869,12 +869,14 @@ var RiverServer = class {
869
869
  log?.error(
870
870
  `${this.transport.clientId} -- can't create a new procedure stream from a message that doesn't have the stream open bit set`
871
871
  );
872
+ log?.debug(` -> ${JSON.stringify(message)}`);
872
873
  return;
873
874
  }
874
875
  if (!message.procedureName || !message.serviceName) {
875
876
  log?.warn(
876
877
  `${this.transport.clientId} -- missing procedure or service name in stream open message`
877
878
  );
879
+ log?.debug(` -> ${JSON.stringify(message)}`);
878
880
  return;
879
881
  }
880
882
  if (!(message.serviceName in this.services)) {
@@ -935,7 +937,7 @@ var RiverServer = class {
935
937
  const errorHandler = (err) => {
936
938
  const errorMsg = coerceErrorString(err);
937
939
  log?.error(
938
- `${this.transport.clientId} -- procedure ${message.serviceName}.${message.procedureName}:${message.streamId} threw an error: ${errorMsg}`
940
+ `${this.transport.clientId} -- procedure ${message.serviceName}.${message.procedureName}:${message.streamId} threw an uncaught error: ${errorMsg}`
939
941
  );
940
942
  outgoing.push(
941
943
  Err({
@@ -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-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';
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-8c80cf47.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-8c80cf47.js';
3
+ import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-047087cb.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-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';
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-8c80cf47.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-8c80cf47.js';
3
+ import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-047087cb.js';
4
4
  import { Pushable } from 'it-pushable';
5
5
  import { Static } from '@sinclair/typebox';
6
6
  import '../types-3e5768ec.js';
@@ -8,7 +8,7 @@ import {
8
8
  createClient,
9
9
  createServer,
10
10
  serializeService
11
- } from "../chunk-E2CP4UWB.js";
11
+ } from "../chunk-KUQ4OT4D.js";
12
12
  import "../chunk-GFRAOY75.js";
13
13
  import "../chunk-H4BYJELI.js";
14
14
  export {
@@ -188,11 +188,11 @@ var Session = class {
188
188
  */
189
189
  debugId;
190
190
  /**
191
- * Number of messages we've sent along this session (excluding handshake)
191
+ * Number of messages we've sent along this session (excluding handshake and acks)
192
192
  */
193
193
  seq = 0;
194
194
  /**
195
- * Number of unique messages we've received this session (excluding handshake)
195
+ * Number of unique messages we've received this session (excluding handshake and acks)
196
196
  */
197
197
  ack = 0;
198
198
  /**
@@ -256,21 +256,13 @@ var Session = class {
256
256
  }
257
257
  return;
258
258
  }
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,
259
+ this.send({
267
260
  streamId: "heartbeat",
268
261
  controlFlags: 1 /* AckBit */,
269
262
  payload: {
270
263
  type: "ACK"
271
264
  }
272
- };
273
- this.connection.send(this.codec.toBuffer(heartbeatBuff));
265
+ });
274
266
  this.heartbeatMisses++;
275
267
  }
276
268
  resetBufferedMessages() {
@@ -861,12 +853,14 @@ var ClientTransport = class extends Transport {
861
853
  }
862
854
  let reconnectPromise = this.inflightConnectionPromises.get(to);
863
855
  if (!reconnectPromise) {
864
- reconnectPromise = this.createNewOutgoingConnection(to);
856
+ reconnectPromise = this.createNewOutgoingConnection(to).then((conn) => {
857
+ this.sendHandshake(to, conn);
858
+ return conn;
859
+ });
865
860
  this.inflightConnectionPromises.set(to, reconnectPromise);
866
861
  }
867
862
  try {
868
- const conn = await reconnectPromise;
869
- this.sendHandshake(to, conn);
863
+ await reconnectPromise;
870
864
  } catch (error) {
871
865
  const errStr = coerceErrorString(error);
872
866
  this.inflightConnectionPromises.delete(to);
@@ -1,5 +1,5 @@
1
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-56a709fc.js';
2
- import { U as UdsConnection } from '../../../connection-ba6a843a.js';
1
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-047087cb.js';
2
+ import { U as UdsConnection } from '../../../connection-ebd00fd5.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-56a709fc.js';
2
- import { U as UdsConnection } from '../../../connection-ba6a843a.js';
1
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-047087cb.js';
2
+ import { U as UdsConnection } from '../../../connection-ebd00fd5.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-65O4MCJZ.js";
3
+ } from "../../../chunk-44GN4JUR.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-ZIGZKCDJ.js";
6
+ } from "../../../chunk-5ETR5EVH.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import {
9
9
  log
@@ -226,11 +226,11 @@ var Session = class {
226
226
  */
227
227
  debugId;
228
228
  /**
229
- * Number of messages we've sent along this session (excluding handshake)
229
+ * Number of messages we've sent along this session (excluding handshake and acks)
230
230
  */
231
231
  seq = 0;
232
232
  /**
233
- * Number of unique messages we've received this session (excluding handshake)
233
+ * Number of unique messages we've received this session (excluding handshake and acks)
234
234
  */
235
235
  ack = 0;
236
236
  /**
@@ -294,21 +294,13 @@ var Session = class {
294
294
  }
295
295
  return;
296
296
  }
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,
297
+ this.send({
305
298
  streamId: "heartbeat",
306
299
  controlFlags: 1 /* AckBit */,
307
300
  payload: {
308
301
  type: "ACK"
309
302
  }
310
- };
311
- this.connection.send(this.codec.toBuffer(heartbeatBuff));
303
+ });
312
304
  this.heartbeatMisses++;
313
305
  }
314
306
  resetBufferedMessages() {
@@ -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-56a709fc.js';
3
- import { U as UdsConnection } from '../../../connection-ba6a843a.js';
2
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-047087cb.js';
3
+ import { U as UdsConnection } from '../../../connection-ebd00fd5.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-56a709fc.js';
3
- import { U as UdsConnection } from '../../../connection-ba6a843a.js';
2
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-047087cb.js';
3
+ import { U as UdsConnection } from '../../../connection-ebd00fd5.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-65O4MCJZ.js";
3
+ } from "../../../chunk-44GN4JUR.js";
4
4
  import {
5
5
  ServerTransport
6
- } from "../../../chunk-ZIGZKCDJ.js";
6
+ } from "../../../chunk-5ETR5EVH.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import {
9
9
  log
@@ -218,11 +218,11 @@ var Session = class {
218
218
  */
219
219
  debugId;
220
220
  /**
221
- * Number of messages we've sent along this session (excluding handshake)
221
+ * Number of messages we've sent along this session (excluding handshake and acks)
222
222
  */
223
223
  seq = 0;
224
224
  /**
225
- * Number of unique messages we've received this session (excluding handshake)
225
+ * Number of unique messages we've received this session (excluding handshake and acks)
226
226
  */
227
227
  ack = 0;
228
228
  /**
@@ -286,21 +286,13 @@ var Session = class {
286
286
  }
287
287
  return;
288
288
  }
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,
289
+ this.send({
297
290
  streamId: "heartbeat",
298
291
  controlFlags: 1 /* AckBit */,
299
292
  payload: {
300
293
  type: "ACK"
301
294
  }
302
- };
303
- this.connection.send(this.codec.toBuffer(heartbeatBuff));
295
+ });
304
296
  this.heartbeatMisses++;
305
297
  }
306
298
  resetBufferedMessages() {
@@ -767,12 +759,14 @@ var ClientTransport = class extends Transport {
767
759
  }
768
760
  let reconnectPromise = this.inflightConnectionPromises.get(to);
769
761
  if (!reconnectPromise) {
770
- reconnectPromise = this.createNewOutgoingConnection(to);
762
+ reconnectPromise = this.createNewOutgoingConnection(to).then((conn) => {
763
+ this.sendHandshake(to, conn);
764
+ return conn;
765
+ });
771
766
  this.inflightConnectionPromises.set(to, reconnectPromise);
772
767
  }
773
768
  try {
774
- const conn = await reconnectPromise;
775
- this.sendHandshake(to, conn);
769
+ await reconnectPromise;
776
770
  } catch (error) {
777
771
  const errStr = coerceErrorString(error);
778
772
  this.inflightConnectionPromises.delete(to);
@@ -1,6 +1,6 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-56a709fc.js';
3
- import { W as WebSocketConnection } from '../../../connection-ede51542.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-047087cb.js';
3
+ import { W as WebSocketConnection } from '../../../connection-88c9269b.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-56a709fc.js';
3
- import { W as WebSocketConnection } from '../../../connection-ede51542.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-047087cb.js';
3
+ import { W as WebSocketConnection } from '../../../connection-88c9269b.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-L62HCTWX.js";
3
+ } from "../../../chunk-IPSTJ7NW.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-ZIGZKCDJ.js";
6
+ } from "../../../chunk-5ETR5EVH.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import {
9
9
  log
@@ -226,11 +226,11 @@ var Session = class {
226
226
  */
227
227
  debugId;
228
228
  /**
229
- * Number of messages we've sent along this session (excluding handshake)
229
+ * Number of messages we've sent along this session (excluding handshake and acks)
230
230
  */
231
231
  seq = 0;
232
232
  /**
233
- * Number of unique messages we've received this session (excluding handshake)
233
+ * Number of unique messages we've received this session (excluding handshake and acks)
234
234
  */
235
235
  ack = 0;
236
236
  /**
@@ -294,21 +294,13 @@ var Session = class {
294
294
  }
295
295
  return;
296
296
  }
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,
297
+ this.send({
305
298
  streamId: "heartbeat",
306
299
  controlFlags: 1 /* AckBit */,
307
300
  payload: {
308
301
  type: "ACK"
309
302
  }
310
- };
311
- this.connection.send(this.codec.toBuffer(heartbeatBuff));
303
+ });
312
304
  this.heartbeatMisses++;
313
305
  }
314
306
  resetBufferedMessages() {
@@ -1,7 +1,7 @@
1
- import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-56a709fc.js';
1
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-047087cb.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-ede51542.js';
4
+ import { W as WebSocketConnection } from '../../../connection-88c9269b.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-56a709fc.js';
1
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-047087cb.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-ede51542.js';
4
+ import { W as WebSocketConnection } from '../../../connection-88c9269b.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-L62HCTWX.js";
3
+ } from "../../../chunk-IPSTJ7NW.js";
4
4
  import {
5
5
  ServerTransport
6
- } from "../../../chunk-ZIGZKCDJ.js";
6
+ } from "../../../chunk-5ETR5EVH.js";
7
7
  import "../../../chunk-GFRAOY75.js";
8
8
  import "../../../chunk-H4BYJELI.js";
9
9
  import "../../../chunk-GZ7HCLLM.js";
@@ -248,11 +248,11 @@ var Session = class {
248
248
  */
249
249
  debugId;
250
250
  /**
251
- * Number of messages we've sent along this session (excluding handshake)
251
+ * Number of messages we've sent along this session (excluding handshake and acks)
252
252
  */
253
253
  seq = 0;
254
254
  /**
255
- * Number of unique messages we've received this session (excluding handshake)
255
+ * Number of unique messages we've received this session (excluding handshake and acks)
256
256
  */
257
257
  ack = 0;
258
258
  /**
@@ -316,21 +316,13 @@ var Session = class {
316
316
  }
317
317
  return;
318
318
  }
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,
319
+ this.send({
327
320
  streamId: "heartbeat",
328
321
  controlFlags: 1 /* AckBit */,
329
322
  payload: {
330
323
  type: "ACK"
331
324
  }
332
- };
333
- this.connection.send(this.codec.toBuffer(heartbeatBuff));
325
+ });
334
326
  this.heartbeatMisses++;
335
327
  }
336
328
  resetBufferedMessages() {
@@ -797,12 +789,14 @@ var ClientTransport = class extends Transport {
797
789
  }
798
790
  let reconnectPromise = this.inflightConnectionPromises.get(to);
799
791
  if (!reconnectPromise) {
800
- reconnectPromise = this.createNewOutgoingConnection(to);
792
+ reconnectPromise = this.createNewOutgoingConnection(to).then((conn) => {
793
+ this.sendHandshake(to, conn);
794
+ return conn;
795
+ });
801
796
  this.inflightConnectionPromises.set(to, reconnectPromise);
802
797
  }
803
798
  try {
804
- const conn = await reconnectPromise;
805
- this.sendHandshake(to, conn);
799
+ await reconnectPromise;
806
800
  } catch (error) {
807
801
  const errStr = coerceErrorString(error);
808
802
  this.inflightConnectionPromises.delete(to);
@@ -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-56a709fc.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-047087cb.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-56a709fc.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-047087cb.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-ZIGZKCDJ.js";
8
+ } from "../chunk-5ETR5EVH.js";
9
9
  import {
10
10
  OpaqueTransportMessageSchema,
11
11
  TransportMessageSchema
@@ -136,11 +136,11 @@ var Session = class {
136
136
  */
137
137
  debugId;
138
138
  /**
139
- * Number of messages we've sent along this session (excluding handshake)
139
+ * Number of messages we've sent along this session (excluding handshake and acks)
140
140
  */
141
141
  seq = 0;
142
142
  /**
143
- * Number of unique messages we've received this session (excluding handshake)
143
+ * Number of unique messages we've received this session (excluding handshake and acks)
144
144
  */
145
145
  ack = 0;
146
146
  /**
@@ -204,21 +204,13 @@ var Session = class {
204
204
  }
205
205
  return;
206
206
  }
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,
207
+ this.send({
215
208
  streamId: "heartbeat",
216
209
  controlFlags: 1 /* AckBit */,
217
210
  payload: {
218
211
  type: "ACK"
219
212
  }
220
- };
221
- this.connection.send(this.codec.toBuffer(heartbeatBuff));
213
+ });
222
214
  this.heartbeatMisses++;
223
215
  }
224
216
  resetBufferedMessages() {
@@ -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-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';
4
+ import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-047087cb.js';
5
+ import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-8c80cf47.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-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';
4
+ import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-047087cb.js';
5
+ import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-8c80cf47.js';
6
6
  import { Static } from '@sinclair/typebox';
7
7
  import net from 'node:net';
8
8
  import '../types-3e5768ec.js';
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  UNCAUGHT_ERROR,
3
3
  pushable
4
- } from "../chunk-E2CP4UWB.js";
4
+ } from "../chunk-KUQ4OT4D.js";
5
5
  import "../chunk-5IZ2UHWV.js";
6
6
  import {
7
7
  Session,
8
8
  defaultSessionOptions
9
- } from "../chunk-ZIGZKCDJ.js";
9
+ } from "../chunk-5ETR5EVH.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.8",
4
+ "version": "0.13.10",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {