@replit/river 0.12.5 → 0.12.6

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 (41) hide show
  1. package/dist/{chunk-2PKONGC3.js → chunk-4SDJ5VN4.js} +10 -19
  2. package/dist/{chunk-7J66WOIC.js → chunk-PBPXYLI6.js} +1 -1
  3. package/dist/{chunk-H4QR2K3T.js → chunk-Q7GL34DZ.js} +1 -1
  4. package/dist/{chunk-6OAKPO5R.js → chunk-VLBVQX5H.js} +1 -1
  5. package/dist/{connection-64b9e0ff.d.ts → connection-1f9971d8.d.ts} +1 -1
  6. package/dist/{connection-a6cc48e8.d.ts → connection-24d878ac.d.ts} +1 -1
  7. package/dist/{connection-4a839b9a.d.ts → connection-ba37d174.d.ts} +1 -1
  8. package/dist/{index-1afc5580.d.ts → index-54e0f99c.d.ts} +5 -7
  9. package/dist/router/index.d.cts +1 -1
  10. package/dist/router/index.d.ts +1 -1
  11. package/dist/transport/impls/stdio/client.cjs +10 -19
  12. package/dist/transport/impls/stdio/client.d.cts +2 -2
  13. package/dist/transport/impls/stdio/client.d.ts +2 -2
  14. package/dist/transport/impls/stdio/client.js +2 -2
  15. package/dist/transport/impls/stdio/server.cjs +10 -19
  16. package/dist/transport/impls/stdio/server.d.cts +2 -2
  17. package/dist/transport/impls/stdio/server.d.ts +2 -2
  18. package/dist/transport/impls/stdio/server.js +2 -2
  19. package/dist/transport/impls/uds/client.cjs +10 -19
  20. package/dist/transport/impls/uds/client.d.cts +2 -2
  21. package/dist/transport/impls/uds/client.d.ts +2 -2
  22. package/dist/transport/impls/uds/client.js +2 -2
  23. package/dist/transport/impls/uds/server.cjs +10 -19
  24. package/dist/transport/impls/uds/server.d.cts +2 -2
  25. package/dist/transport/impls/uds/server.d.ts +2 -2
  26. package/dist/transport/impls/uds/server.js +2 -2
  27. package/dist/transport/impls/ws/client.cjs +10 -19
  28. package/dist/transport/impls/ws/client.d.cts +2 -2
  29. package/dist/transport/impls/ws/client.d.ts +2 -2
  30. package/dist/transport/impls/ws/client.js +2 -2
  31. package/dist/transport/impls/ws/server.cjs +10 -19
  32. package/dist/transport/impls/ws/server.d.cts +2 -2
  33. package/dist/transport/impls/ws/server.d.ts +2 -2
  34. package/dist/transport/impls/ws/server.js +2 -2
  35. package/dist/transport/index.cjs +10 -19
  36. package/dist/transport/index.d.cts +1 -1
  37. package/dist/transport/index.d.ts +1 -1
  38. package/dist/transport/index.js +1 -1
  39. package/dist/util/testHelpers.d.cts +1 -1
  40. package/dist/util/testHelpers.d.ts +1 -1
  41. package/package.json +1 -1
@@ -204,9 +204,7 @@ var Session = class {
204
204
  this.cancelGrace();
205
205
  this.connection = newConn;
206
206
  }
207
- graceCb;
208
207
  beginGrace(cb) {
209
- this.graceCb = cb;
210
208
  this.disconnectionGrace = setTimeout(() => {
211
209
  this.close();
212
210
  cb();
@@ -222,8 +220,8 @@ var Session = class {
222
220
  close() {
223
221
  this.closeStaleConnection(this.connection);
224
222
  this.cancelGrace();
225
- clearInterval(this.heartbeat);
226
223
  this.resetBufferedMessages();
224
+ clearInterval(this.heartbeat);
227
225
  }
228
226
  get connected() {
229
227
  return this.connection !== void 0;
@@ -314,15 +312,6 @@ var Transport = class {
314
312
  this.clientId = clientId;
315
313
  this.state = "open";
316
314
  }
317
- sessionByClientId(clientId) {
318
- const session = this.sessions.get(clientId);
319
- if (!session) {
320
- const err = `${this.clientId} -- (invariant violation) no existing session for ${clientId}`;
321
- log?.error(err);
322
- throw new Error(err);
323
- }
324
- return session;
325
- }
326
315
  /**
327
316
  * Called when a new connection is established
328
317
  * and we know the identity of the connected client.
@@ -392,13 +381,10 @@ var Transport = class {
392
381
  status: "disconnect",
393
382
  conn
394
383
  });
395
- if (this.state !== "open")
384
+ const session = this.sessions.get(connectedTo);
385
+ if (!session)
396
386
  return;
397
- const session = this.sessionByClientId(connectedTo);
398
- log?.info(
399
- `${this.clientId} -- connection (id: ${conn.debugId}) disconnect from ${connectedTo}, ${SESSION_DISCONNECT_GRACE_MS}ms until session (id: ${session.debugId}) disconnect`
400
- );
401
- session.closeStaleConnection(conn);
387
+ session.connection = void 0;
402
388
  session.beginGrace(() => this.deleteSession(session));
403
389
  }
404
390
  /**
@@ -437,7 +423,12 @@ var Transport = class {
437
423
  handleMsg(msg) {
438
424
  if (this.state !== "open")
439
425
  return;
440
- const session = this.sessionByClientId(msg.from);
426
+ const session = this.sessions.get(msg.from);
427
+ if (!session) {
428
+ const err = `${this.clientId} -- (invariant violation) no existing session for ${msg.from}`;
429
+ log?.error(err);
430
+ return;
431
+ }
441
432
  session.cancelGrace();
442
433
  log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
443
434
  if (msg.seq !== session.nextExpectedSeq) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-IIBVKYDB.js";
4
4
  import {
5
5
  Connection
6
- } from "./chunk-2PKONGC3.js";
6
+ } from "./chunk-4SDJ5VN4.js";
7
7
 
8
8
  // transport/impls/uds/connection.ts
9
9
  var UdsConnection = class extends Connection {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-IIBVKYDB.js";
4
4
  import {
5
5
  Connection
6
- } from "./chunk-2PKONGC3.js";
6
+ } from "./chunk-4SDJ5VN4.js";
7
7
 
8
8
  // transport/impls/stdio/connection.ts
9
9
  var StreamConnection = class extends Connection {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Connection
3
- } from "./chunk-2PKONGC3.js";
3
+ } from "./chunk-4SDJ5VN4.js";
4
4
 
5
5
  // transport/impls/ws/connection.ts
6
6
  var WebSocketConnection = class extends Connection {
@@ -1,4 +1,4 @@
1
- import { C as Connection } from './index-1afc5580.js';
1
+ import { C as Connection } from './index-54e0f99c.js';
2
2
  import { U as Uint32LengthPrefixFraming } from './messageFraming-b200ef25.js';
3
3
 
4
4
  declare class StreamConnection extends Connection {
@@ -1,4 +1,4 @@
1
- import { C as Connection } from './index-1afc5580.js';
1
+ import { C as Connection } from './index-54e0f99c.js';
2
2
  import { Socket } from 'node:net';
3
3
  import { U as Uint32LengthPrefixFraming } from './messageFraming-b200ef25.js';
4
4
 
@@ -1,5 +1,5 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { C as Connection } from './index-1afc5580.js';
2
+ import { C as Connection } from './index-54e0f99c.js';
3
3
 
4
4
  declare class WebSocketConnection extends Connection {
5
5
  ws: WebSocket;
@@ -214,7 +214,6 @@ declare class Session<ConnType extends Connection> {
214
214
  addToSendBuff(msg: TransportMessage): void;
215
215
  closeStaleConnection(conn?: ConnType): void;
216
216
  replaceWithNewConnection(newConn: ConnType): void;
217
- graceCb?: () => unknown;
218
217
  beginGrace(cb: () => void): void;
219
218
  cancelGrace(): void;
220
219
  close(): void;
@@ -333,7 +332,6 @@ declare abstract class Transport<ConnType extends Connection> {
333
332
  * @param clientId The client ID of this transport.
334
333
  */
335
334
  constructor(clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
336
- private sessionByClientId;
337
335
  /**
338
336
  * This is called immediately after a new connection is established and we
339
337
  * may or may not know the identity of the connected client.
@@ -356,7 +354,7 @@ declare abstract class Transport<ConnType extends Connection> {
356
354
  * @param conn The connection object.
357
355
  * @param connectedTo The peer we are connected to.
358
356
  */
359
- onDisconnect(conn: ConnType, connectedTo: TransportClientId): void;
357
+ protected onDisconnect(conn: ConnType, connectedTo: TransportClientId): void;
360
358
  /**
361
359
  * Parses a message from a Uint8Array into a {@link OpaqueTransportMessage}.
362
360
  * @param msg The message to parse.
@@ -368,7 +366,7 @@ declare abstract class Transport<ConnType extends Connection> {
368
366
  * You generally shouldn't need to override this in downstream transport implementations.
369
367
  * @param msg The received message.
370
368
  */
371
- handleMsg(msg: OpaqueTransportMessage): void;
369
+ protected handleMsg(msg: OpaqueTransportMessage): void;
372
370
  /**
373
371
  * Adds a listener to this transport.
374
372
  * @param the type of event to listen for
@@ -424,13 +422,13 @@ declare abstract class ClientTransport<ConnType extends Connection> extends Tran
424
422
  * @param to The client ID of the node to connect to.
425
423
  */
426
424
  connect(to: TransportClientId, attempt?: number): Promise<void>;
427
- receiveWithBootSequence(conn: ConnType, sessionCb: (sess: Session<ConnType>) => void): (data: Uint8Array) => void;
428
- onDisconnect(conn: ConnType, connectedTo: string): void;
425
+ private receiveWithBootSequence;
426
+ protected onDisconnect(conn: ConnType, connectedTo: string): void;
429
427
  }
430
428
  declare abstract class ServerTransport<ConnType extends Connection> extends Transport<ConnType> {
431
429
  constructor(clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
432
430
  protected handleConnection(conn: ConnType): void;
433
- receiveWithBootSequence(conn: ConnType, sessionCb: (sess: Session<ConnType>) => void): (data: Uint8Array) => void;
431
+ protected receiveWithBootSequence(conn: ConnType, sessionCb: (sess: Session<ConnType>) => void): (data: Uint8Array) => void;
434
432
  }
435
433
 
436
434
  export { Connection as C, EventMap as E, OpaqueTransportMessage as O, PartialTransportMessage as P, ServerTransport as S, Transport as T, ClientTransport as a, TransportClientId as b, TransportOptions as c, Session as d, TransportMessageSchema as e, OpaqueTransportMessageSchema as f, TransportMessage as g, isStreamClose as h, isStreamOpen as i, EventTypes as j, EventHandler as k };
@@ -1,6 +1,6 @@
1
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-c593de11.js';
2
2
  export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, o as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-c593de11.js';
3
- import { T as Transport, C as Connection, b as TransportClientId } from '../index-1afc5580.js';
3
+ import { T as Transport, C as Connection, b as TransportClientId } from '../index-54e0f99c.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
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-c593de11.js';
2
2
  export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, o as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-c593de11.js';
3
- import { T as Transport, C as Connection, b as TransportClientId } from '../index-1afc5580.js';
3
+ import { T as Transport, C as Connection, b as TransportClientId } from '../index-54e0f99c.js';
4
4
  import { Pushable } from 'it-pushable';
5
5
  import { Static } from '@sinclair/typebox';
6
6
  import '../types-3e5768ec.js';
@@ -288,9 +288,7 @@ var Session = class {
288
288
  this.cancelGrace();
289
289
  this.connection = newConn;
290
290
  }
291
- graceCb;
292
291
  beginGrace(cb) {
293
- this.graceCb = cb;
294
292
  this.disconnectionGrace = setTimeout(() => {
295
293
  this.close();
296
294
  cb();
@@ -306,8 +304,8 @@ var Session = class {
306
304
  close() {
307
305
  this.closeStaleConnection(this.connection);
308
306
  this.cancelGrace();
309
- clearInterval(this.heartbeat);
310
307
  this.resetBufferedMessages();
308
+ clearInterval(this.heartbeat);
311
309
  }
312
310
  get connected() {
313
311
  return this.connection !== void 0;
@@ -459,15 +457,6 @@ var Transport = class {
459
457
  this.clientId = clientId;
460
458
  this.state = "open";
461
459
  }
462
- sessionByClientId(clientId) {
463
- const session = this.sessions.get(clientId);
464
- if (!session) {
465
- const err = `${this.clientId} -- (invariant violation) no existing session for ${clientId}`;
466
- log?.error(err);
467
- throw new Error(err);
468
- }
469
- return session;
470
- }
471
460
  /**
472
461
  * Called when a new connection is established
473
462
  * and we know the identity of the connected client.
@@ -537,13 +526,10 @@ var Transport = class {
537
526
  status: "disconnect",
538
527
  conn
539
528
  });
540
- if (this.state !== "open")
529
+ const session = this.sessions.get(connectedTo);
530
+ if (!session)
541
531
  return;
542
- const session = this.sessionByClientId(connectedTo);
543
- log?.info(
544
- `${this.clientId} -- connection (id: ${conn.debugId}) disconnect from ${connectedTo}, ${SESSION_DISCONNECT_GRACE_MS}ms until session (id: ${session.debugId}) disconnect`
545
- );
546
- session.closeStaleConnection(conn);
532
+ session.connection = void 0;
547
533
  session.beginGrace(() => this.deleteSession(session));
548
534
  }
549
535
  /**
@@ -582,7 +568,12 @@ var Transport = class {
582
568
  handleMsg(msg) {
583
569
  if (this.state !== "open")
584
570
  return;
585
- const session = this.sessionByClientId(msg.from);
571
+ const session = this.sessions.get(msg.from);
572
+ if (!session) {
573
+ const err = `${this.clientId} -- (invariant violation) no existing session for ${msg.from}`;
574
+ log?.error(err);
575
+ return;
576
+ }
586
577
  session.cancelGrace();
587
578
  log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
588
579
  if (msg.seq !== session.nextExpectedSeq) {
@@ -1,5 +1,5 @@
1
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-1afc5580.js';
2
- import { S as StreamConnection } from '../../../connection-64b9e0ff.js';
1
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
2
+ import { S as StreamConnection } from '../../../connection-1f9971d8.js';
3
3
  import '../../../types-3e5768ec.js';
4
4
  import '@sinclair/typebox';
5
5
  import '../../../messageFraming-b200ef25.js';
@@ -1,5 +1,5 @@
1
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-1afc5580.js';
2
- import { S as StreamConnection } from '../../../connection-64b9e0ff.js';
1
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
2
+ import { S as StreamConnection } from '../../../connection-1f9971d8.js';
3
3
  import '../../../types-3e5768ec.js';
4
4
  import '@sinclair/typebox';
5
5
  import '../../../messageFraming-b200ef25.js';
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  StreamConnection
3
- } from "../../../chunk-H4QR2K3T.js";
3
+ } from "../../../chunk-Q7GL34DZ.js";
4
4
  import "../../../chunk-5IZ2UHWV.js";
5
5
  import "../../../chunk-IIBVKYDB.js";
6
6
  import {
7
7
  ClientTransport
8
- } from "../../../chunk-2PKONGC3.js";
8
+ } from "../../../chunk-4SDJ5VN4.js";
9
9
  import "../../../chunk-GZ7HCLLM.js";
10
10
  import "../../../chunk-XFFS4UOD.js";
11
11
  import {
@@ -296,9 +296,7 @@ var Session = class {
296
296
  this.cancelGrace();
297
297
  this.connection = newConn;
298
298
  }
299
- graceCb;
300
299
  beginGrace(cb) {
301
- this.graceCb = cb;
302
300
  this.disconnectionGrace = setTimeout(() => {
303
301
  this.close();
304
302
  cb();
@@ -314,8 +312,8 @@ var Session = class {
314
312
  close() {
315
313
  this.closeStaleConnection(this.connection);
316
314
  this.cancelGrace();
317
- clearInterval(this.heartbeat);
318
315
  this.resetBufferedMessages();
316
+ clearInterval(this.heartbeat);
319
317
  }
320
318
  get connected() {
321
319
  return this.connection !== void 0;
@@ -467,15 +465,6 @@ var Transport = class {
467
465
  this.clientId = clientId;
468
466
  this.state = "open";
469
467
  }
470
- sessionByClientId(clientId) {
471
- const session = this.sessions.get(clientId);
472
- if (!session) {
473
- const err = `${this.clientId} -- (invariant violation) no existing session for ${clientId}`;
474
- log?.error(err);
475
- throw new Error(err);
476
- }
477
- return session;
478
- }
479
468
  /**
480
469
  * Called when a new connection is established
481
470
  * and we know the identity of the connected client.
@@ -545,13 +534,10 @@ var Transport = class {
545
534
  status: "disconnect",
546
535
  conn
547
536
  });
548
- if (this.state !== "open")
537
+ const session = this.sessions.get(connectedTo);
538
+ if (!session)
549
539
  return;
550
- const session = this.sessionByClientId(connectedTo);
551
- log?.info(
552
- `${this.clientId} -- connection (id: ${conn.debugId}) disconnect from ${connectedTo}, ${SESSION_DISCONNECT_GRACE_MS}ms until session (id: ${session.debugId}) disconnect`
553
- );
554
- session.closeStaleConnection(conn);
540
+ session.connection = void 0;
555
541
  session.beginGrace(() => this.deleteSession(session));
556
542
  }
557
543
  /**
@@ -590,7 +576,12 @@ var Transport = class {
590
576
  handleMsg(msg) {
591
577
  if (this.state !== "open")
592
578
  return;
593
- const session = this.sessionByClientId(msg.from);
579
+ const session = this.sessions.get(msg.from);
580
+ if (!session) {
581
+ const err = `${this.clientId} -- (invariant violation) no existing session for ${msg.from}`;
582
+ log?.error(err);
583
+ return;
584
+ }
594
585
  session.cancelGrace();
595
586
  log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
596
587
  if (msg.seq !== session.nextExpectedSeq) {
@@ -1,5 +1,5 @@
1
- import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-1afc5580.js';
2
- import { S as StreamConnection } from '../../../connection-64b9e0ff.js';
1
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
2
+ import { S as StreamConnection } from '../../../connection-1f9971d8.js';
3
3
  import '../../../types-3e5768ec.js';
4
4
  import '@sinclair/typebox';
5
5
  import '../../../messageFraming-b200ef25.js';
@@ -1,5 +1,5 @@
1
- import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-1afc5580.js';
2
- import { S as StreamConnection } from '../../../connection-64b9e0ff.js';
1
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
2
+ import { S as StreamConnection } from '../../../connection-1f9971d8.js';
3
3
  import '../../../types-3e5768ec.js';
4
4
  import '@sinclair/typebox';
5
5
  import '../../../messageFraming-b200ef25.js';
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  StreamConnection
3
- } from "../../../chunk-H4QR2K3T.js";
3
+ } from "../../../chunk-Q7GL34DZ.js";
4
4
  import "../../../chunk-5IZ2UHWV.js";
5
5
  import "../../../chunk-IIBVKYDB.js";
6
6
  import {
7
7
  ServerTransport
8
- } from "../../../chunk-2PKONGC3.js";
8
+ } from "../../../chunk-4SDJ5VN4.js";
9
9
  import "../../../chunk-GZ7HCLLM.js";
10
10
  import "../../../chunk-XFFS4UOD.js";
11
11
  import "../../../chunk-H4BYJELI.js";
@@ -260,9 +260,7 @@ var Session = class {
260
260
  this.cancelGrace();
261
261
  this.connection = newConn;
262
262
  }
263
- graceCb;
264
263
  beginGrace(cb) {
265
- this.graceCb = cb;
266
264
  this.disconnectionGrace = setTimeout(() => {
267
265
  this.close();
268
266
  cb();
@@ -278,8 +276,8 @@ var Session = class {
278
276
  close() {
279
277
  this.closeStaleConnection(this.connection);
280
278
  this.cancelGrace();
281
- clearInterval(this.heartbeat);
282
279
  this.resetBufferedMessages();
280
+ clearInterval(this.heartbeat);
283
281
  }
284
282
  get connected() {
285
283
  return this.connection !== void 0;
@@ -555,15 +553,6 @@ var Transport = class {
555
553
  this.clientId = clientId;
556
554
  this.state = "open";
557
555
  }
558
- sessionByClientId(clientId) {
559
- const session = this.sessions.get(clientId);
560
- if (!session) {
561
- const err = `${this.clientId} -- (invariant violation) no existing session for ${clientId}`;
562
- log?.error(err);
563
- throw new Error(err);
564
- }
565
- return session;
566
- }
567
556
  /**
568
557
  * Called when a new connection is established
569
558
  * and we know the identity of the connected client.
@@ -633,13 +622,10 @@ var Transport = class {
633
622
  status: "disconnect",
634
623
  conn
635
624
  });
636
- if (this.state !== "open")
625
+ const session = this.sessions.get(connectedTo);
626
+ if (!session)
637
627
  return;
638
- const session = this.sessionByClientId(connectedTo);
639
- log?.info(
640
- `${this.clientId} -- connection (id: ${conn.debugId}) disconnect from ${connectedTo}, ${SESSION_DISCONNECT_GRACE_MS}ms until session (id: ${session.debugId}) disconnect`
641
- );
642
- session.closeStaleConnection(conn);
628
+ session.connection = void 0;
643
629
  session.beginGrace(() => this.deleteSession(session));
644
630
  }
645
631
  /**
@@ -678,7 +664,12 @@ var Transport = class {
678
664
  handleMsg(msg) {
679
665
  if (this.state !== "open")
680
666
  return;
681
- const session = this.sessionByClientId(msg.from);
667
+ const session = this.sessions.get(msg.from);
668
+ if (!session) {
669
+ const err = `${this.clientId} -- (invariant violation) no existing session for ${msg.from}`;
670
+ log?.error(err);
671
+ return;
672
+ }
682
673
  session.cancelGrace();
683
674
  log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
684
675
  if (msg.seq !== session.nextExpectedSeq) {
@@ -1,5 +1,5 @@
1
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-1afc5580.js';
2
- import { U as UdsConnection } from '../../../connection-a6cc48e8.js';
1
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
2
+ import { U as UdsConnection } from '../../../connection-24d878ac.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-1afc5580.js';
2
- import { U as UdsConnection } from '../../../connection-a6cc48e8.js';
1
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
2
+ import { U as UdsConnection } from '../../../connection-24d878ac.js';
3
3
  import '../../../types-3e5768ec.js';
4
4
  import '@sinclair/typebox';
5
5
  import 'node:net';
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  UdsConnection
3
- } from "../../../chunk-7J66WOIC.js";
3
+ } from "../../../chunk-PBPXYLI6.js";
4
4
  import "../../../chunk-IIBVKYDB.js";
5
5
  import {
6
6
  ClientTransport
7
- } from "../../../chunk-2PKONGC3.js";
7
+ } from "../../../chunk-4SDJ5VN4.js";
8
8
  import "../../../chunk-GZ7HCLLM.js";
9
9
  import "../../../chunk-XFFS4UOD.js";
10
10
  import {
@@ -296,9 +296,7 @@ var Session = class {
296
296
  this.cancelGrace();
297
297
  this.connection = newConn;
298
298
  }
299
- graceCb;
300
299
  beginGrace(cb) {
301
- this.graceCb = cb;
302
300
  this.disconnectionGrace = setTimeout(() => {
303
301
  this.close();
304
302
  cb();
@@ -314,8 +312,8 @@ var Session = class {
314
312
  close() {
315
313
  this.closeStaleConnection(this.connection);
316
314
  this.cancelGrace();
317
- clearInterval(this.heartbeat);
318
315
  this.resetBufferedMessages();
316
+ clearInterval(this.heartbeat);
319
317
  }
320
318
  get connected() {
321
319
  return this.connection !== void 0;
@@ -467,15 +465,6 @@ var Transport = class {
467
465
  this.clientId = clientId;
468
466
  this.state = "open";
469
467
  }
470
- sessionByClientId(clientId) {
471
- const session = this.sessions.get(clientId);
472
- if (!session) {
473
- const err = `${this.clientId} -- (invariant violation) no existing session for ${clientId}`;
474
- log?.error(err);
475
- throw new Error(err);
476
- }
477
- return session;
478
- }
479
468
  /**
480
469
  * Called when a new connection is established
481
470
  * and we know the identity of the connected client.
@@ -545,13 +534,10 @@ var Transport = class {
545
534
  status: "disconnect",
546
535
  conn
547
536
  });
548
- if (this.state !== "open")
537
+ const session = this.sessions.get(connectedTo);
538
+ if (!session)
549
539
  return;
550
- const session = this.sessionByClientId(connectedTo);
551
- log?.info(
552
- `${this.clientId} -- connection (id: ${conn.debugId}) disconnect from ${connectedTo}, ${SESSION_DISCONNECT_GRACE_MS}ms until session (id: ${session.debugId}) disconnect`
553
- );
554
- session.closeStaleConnection(conn);
540
+ session.connection = void 0;
555
541
  session.beginGrace(() => this.deleteSession(session));
556
542
  }
557
543
  /**
@@ -590,7 +576,12 @@ var Transport = class {
590
576
  handleMsg(msg) {
591
577
  if (this.state !== "open")
592
578
  return;
593
- const session = this.sessionByClientId(msg.from);
579
+ const session = this.sessions.get(msg.from);
580
+ if (!session) {
581
+ const err = `${this.clientId} -- (invariant violation) no existing session for ${msg.from}`;
582
+ log?.error(err);
583
+ return;
584
+ }
594
585
  session.cancelGrace();
595
586
  log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
596
587
  if (msg.seq !== session.nextExpectedSeq) {
@@ -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-1afc5580.js';
3
- import { U as UdsConnection } from '../../../connection-a6cc48e8.js';
2
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
3
+ import { U as UdsConnection } from '../../../connection-24d878ac.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
  import '../../../messageFraming-b200ef25.js';
@@ -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-1afc5580.js';
3
- import { U as UdsConnection } from '../../../connection-a6cc48e8.js';
2
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
3
+ import { U as UdsConnection } from '../../../connection-24d878ac.js';
4
4
  import '../../../types-3e5768ec.js';
5
5
  import '@sinclair/typebox';
6
6
  import '../../../messageFraming-b200ef25.js';
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  UdsConnection
3
- } from "../../../chunk-7J66WOIC.js";
3
+ } from "../../../chunk-PBPXYLI6.js";
4
4
  import "../../../chunk-IIBVKYDB.js";
5
5
  import {
6
6
  ServerTransport
7
- } from "../../../chunk-2PKONGC3.js";
7
+ } from "../../../chunk-4SDJ5VN4.js";
8
8
  import "../../../chunk-GZ7HCLLM.js";
9
9
  import "../../../chunk-XFFS4UOD.js";
10
10
  import {
@@ -288,9 +288,7 @@ var Session = class {
288
288
  this.cancelGrace();
289
289
  this.connection = newConn;
290
290
  }
291
- graceCb;
292
291
  beginGrace(cb) {
293
- this.graceCb = cb;
294
292
  this.disconnectionGrace = setTimeout(() => {
295
293
  this.close();
296
294
  cb();
@@ -306,8 +304,8 @@ var Session = class {
306
304
  close() {
307
305
  this.closeStaleConnection(this.connection);
308
306
  this.cancelGrace();
309
- clearInterval(this.heartbeat);
310
307
  this.resetBufferedMessages();
308
+ clearInterval(this.heartbeat);
311
309
  }
312
310
  get connected() {
313
311
  return this.connection !== void 0;
@@ -459,15 +457,6 @@ var Transport = class {
459
457
  this.clientId = clientId;
460
458
  this.state = "open";
461
459
  }
462
- sessionByClientId(clientId) {
463
- const session = this.sessions.get(clientId);
464
- if (!session) {
465
- const err = `${this.clientId} -- (invariant violation) no existing session for ${clientId}`;
466
- log?.error(err);
467
- throw new Error(err);
468
- }
469
- return session;
470
- }
471
460
  /**
472
461
  * Called when a new connection is established
473
462
  * and we know the identity of the connected client.
@@ -537,13 +526,10 @@ var Transport = class {
537
526
  status: "disconnect",
538
527
  conn
539
528
  });
540
- if (this.state !== "open")
529
+ const session = this.sessions.get(connectedTo);
530
+ if (!session)
541
531
  return;
542
- const session = this.sessionByClientId(connectedTo);
543
- log?.info(
544
- `${this.clientId} -- connection (id: ${conn.debugId}) disconnect from ${connectedTo}, ${SESSION_DISCONNECT_GRACE_MS}ms until session (id: ${session.debugId}) disconnect`
545
- );
546
- session.closeStaleConnection(conn);
532
+ session.connection = void 0;
547
533
  session.beginGrace(() => this.deleteSession(session));
548
534
  }
549
535
  /**
@@ -582,7 +568,12 @@ var Transport = class {
582
568
  handleMsg(msg) {
583
569
  if (this.state !== "open")
584
570
  return;
585
- const session = this.sessionByClientId(msg.from);
571
+ const session = this.sessions.get(msg.from);
572
+ if (!session) {
573
+ const err = `${this.clientId} -- (invariant violation) no existing session for ${msg.from}`;
574
+ log?.error(err);
575
+ return;
576
+ }
586
577
  session.cancelGrace();
587
578
  log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
588
579
  if (msg.seq !== session.nextExpectedSeq) {
@@ -1,6 +1,6 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-1afc5580.js';
3
- import { W as WebSocketConnection } from '../../../connection-4a839b9a.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
3
+ import { W as WebSocketConnection } from '../../../connection-ba37d174.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-1afc5580.js';
3
- import { W as WebSocketConnection } from '../../../connection-4a839b9a.js';
2
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
3
+ import { W as WebSocketConnection } from '../../../connection-ba37d174.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-6OAKPO5R.js";
3
+ } from "../../../chunk-VLBVQX5H.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-2PKONGC3.js";
6
+ } from "../../../chunk-4SDJ5VN4.js";
7
7
  import "../../../chunk-GZ7HCLLM.js";
8
8
  import "../../../chunk-XFFS4UOD.js";
9
9
  import {
@@ -296,9 +296,7 @@ var Session = class {
296
296
  this.cancelGrace();
297
297
  this.connection = newConn;
298
298
  }
299
- graceCb;
300
299
  beginGrace(cb) {
301
- this.graceCb = cb;
302
300
  this.disconnectionGrace = setTimeout(() => {
303
301
  this.close();
304
302
  cb();
@@ -314,8 +312,8 @@ var Session = class {
314
312
  close() {
315
313
  this.closeStaleConnection(this.connection);
316
314
  this.cancelGrace();
317
- clearInterval(this.heartbeat);
318
315
  this.resetBufferedMessages();
316
+ clearInterval(this.heartbeat);
319
317
  }
320
318
  get connected() {
321
319
  return this.connection !== void 0;
@@ -467,15 +465,6 @@ var Transport = class {
467
465
  this.clientId = clientId;
468
466
  this.state = "open";
469
467
  }
470
- sessionByClientId(clientId) {
471
- const session = this.sessions.get(clientId);
472
- if (!session) {
473
- const err = `${this.clientId} -- (invariant violation) no existing session for ${clientId}`;
474
- log?.error(err);
475
- throw new Error(err);
476
- }
477
- return session;
478
- }
479
468
  /**
480
469
  * Called when a new connection is established
481
470
  * and we know the identity of the connected client.
@@ -545,13 +534,10 @@ var Transport = class {
545
534
  status: "disconnect",
546
535
  conn
547
536
  });
548
- if (this.state !== "open")
537
+ const session = this.sessions.get(connectedTo);
538
+ if (!session)
549
539
  return;
550
- const session = this.sessionByClientId(connectedTo);
551
- log?.info(
552
- `${this.clientId} -- connection (id: ${conn.debugId}) disconnect from ${connectedTo}, ${SESSION_DISCONNECT_GRACE_MS}ms until session (id: ${session.debugId}) disconnect`
553
- );
554
- session.closeStaleConnection(conn);
540
+ session.connection = void 0;
555
541
  session.beginGrace(() => this.deleteSession(session));
556
542
  }
557
543
  /**
@@ -590,7 +576,12 @@ var Transport = class {
590
576
  handleMsg(msg) {
591
577
  if (this.state !== "open")
592
578
  return;
593
- const session = this.sessionByClientId(msg.from);
579
+ const session = this.sessions.get(msg.from);
580
+ if (!session) {
581
+ const err = `${this.clientId} -- (invariant violation) no existing session for ${msg.from}`;
582
+ log?.error(err);
583
+ return;
584
+ }
594
585
  session.cancelGrace();
595
586
  log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
596
587
  if (msg.seq !== session.nextExpectedSeq) {
@@ -1,7 +1,7 @@
1
- import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-1afc5580.js';
1
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-4a839b9a.js';
4
+ import { W as WebSocketConnection } from '../../../connection-ba37d174.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-1afc5580.js';
1
+ import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-54e0f99c.js';
2
2
  import { WebSocketServer } from 'ws';
3
3
  import { WebSocket } from 'isomorphic-ws';
4
- import { W as WebSocketConnection } from '../../../connection-4a839b9a.js';
4
+ import { W as WebSocketConnection } from '../../../connection-ba37d174.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-6OAKPO5R.js";
3
+ } from "../../../chunk-VLBVQX5H.js";
4
4
  import {
5
5
  ServerTransport
6
- } from "../../../chunk-2PKONGC3.js";
6
+ } from "../../../chunk-4SDJ5VN4.js";
7
7
  import "../../../chunk-GZ7HCLLM.js";
8
8
  import "../../../chunk-XFFS4UOD.js";
9
9
  import {
@@ -318,9 +318,7 @@ var Session = class {
318
318
  this.cancelGrace();
319
319
  this.connection = newConn;
320
320
  }
321
- graceCb;
322
321
  beginGrace(cb) {
323
- this.graceCb = cb;
324
322
  this.disconnectionGrace = setTimeout(() => {
325
323
  this.close();
326
324
  cb();
@@ -336,8 +334,8 @@ var Session = class {
336
334
  close() {
337
335
  this.closeStaleConnection(this.connection);
338
336
  this.cancelGrace();
339
- clearInterval(this.heartbeat);
340
337
  this.resetBufferedMessages();
338
+ clearInterval(this.heartbeat);
341
339
  }
342
340
  get connected() {
343
341
  return this.connection !== void 0;
@@ -489,15 +487,6 @@ var Transport = class {
489
487
  this.clientId = clientId;
490
488
  this.state = "open";
491
489
  }
492
- sessionByClientId(clientId) {
493
- const session = this.sessions.get(clientId);
494
- if (!session) {
495
- const err = `${this.clientId} -- (invariant violation) no existing session for ${clientId}`;
496
- log?.error(err);
497
- throw new Error(err);
498
- }
499
- return session;
500
- }
501
490
  /**
502
491
  * Called when a new connection is established
503
492
  * and we know the identity of the connected client.
@@ -567,13 +556,10 @@ var Transport = class {
567
556
  status: "disconnect",
568
557
  conn
569
558
  });
570
- if (this.state !== "open")
559
+ const session = this.sessions.get(connectedTo);
560
+ if (!session)
571
561
  return;
572
- const session = this.sessionByClientId(connectedTo);
573
- log?.info(
574
- `${this.clientId} -- connection (id: ${conn.debugId}) disconnect from ${connectedTo}, ${SESSION_DISCONNECT_GRACE_MS}ms until session (id: ${session.debugId}) disconnect`
575
- );
576
- session.closeStaleConnection(conn);
562
+ session.connection = void 0;
577
563
  session.beginGrace(() => this.deleteSession(session));
578
564
  }
579
565
  /**
@@ -612,7 +598,12 @@ var Transport = class {
612
598
  handleMsg(msg) {
613
599
  if (this.state !== "open")
614
600
  return;
615
- const session = this.sessionByClientId(msg.from);
601
+ const session = this.sessions.get(msg.from);
602
+ if (!session) {
603
+ const err = `${this.clientId} -- (invariant violation) no existing session for ${msg.from}`;
604
+ log?.error(err);
605
+ return;
606
+ }
616
607
  session.cancelGrace();
617
608
  log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
618
609
  if (msg.seq !== session.nextExpectedSeq) {
@@ -1,3 +1,3 @@
1
- export { a as ClientTransport, C as Connection, k as EventHandler, E as EventMap, j as EventTypes, O as OpaqueTransportMessage, f as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, g as TransportMessage, e as TransportMessageSchema, h as isStreamClose, i as isStreamOpen } from '../index-1afc5580.js';
1
+ export { a as ClientTransport, C as Connection, k as EventHandler, E as EventMap, j as EventTypes, O as OpaqueTransportMessage, f as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, g as TransportMessage, e as TransportMessageSchema, h as isStreamClose, i as isStreamOpen } from '../index-54e0f99c.js';
2
2
  import '../types-3e5768ec.js';
3
3
  import '@sinclair/typebox';
@@ -1,3 +1,3 @@
1
- export { a as ClientTransport, C as Connection, k as EventHandler, E as EventMap, j as EventTypes, O as OpaqueTransportMessage, f as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, g as TransportMessage, e as TransportMessageSchema, h as isStreamClose, i as isStreamOpen } from '../index-1afc5580.js';
1
+ export { a as ClientTransport, C as Connection, k as EventHandler, E as EventMap, j as EventTypes, O as OpaqueTransportMessage, f as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, g as TransportMessage, e as TransportMessageSchema, h as isStreamClose, i as isStreamOpen } from '../index-54e0f99c.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-2PKONGC3.js";
8
+ } from "../chunk-4SDJ5VN4.js";
9
9
  import "../chunk-GZ7HCLLM.js";
10
10
  import {
11
11
  OpaqueTransportMessageSchema,
@@ -1,7 +1,7 @@
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-1afc5580.js';
4
+ import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-54e0f99c.js';
5
5
  import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-c593de11.js';
6
6
  import { Static } from '@sinclair/typebox';
7
7
  import net from 'node:net';
@@ -1,7 +1,7 @@
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-1afc5580.js';
4
+ import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-54e0f99c.js';
5
5
  import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-c593de11.js';
6
6
  import { Static } from '@sinclair/typebox';
7
7
  import net from 'node:net';
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.12.5",
4
+ "version": "0.12.6",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {