@replit/river 0.12.1 → 0.12.3

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 (45) hide show
  1. package/dist/{chunk-QEYN2Z6O.js → chunk-2PKONGC3.js} +39 -35
  2. package/dist/{chunk-RDTTKCGV.js → chunk-6OAKPO5R.js} +1 -1
  3. package/dist/{chunk-TKINU53F.js → chunk-7J66WOIC.js} +1 -1
  4. package/dist/{chunk-55XUAPC6.js → chunk-AFLZ6INU.js} +1 -1
  5. package/dist/{chunk-M6LY25P2.js → chunk-H4QR2K3T.js} +1 -1
  6. package/dist/{connection-eb10d250.d.ts → connection-4a839b9a.d.ts} +1 -1
  7. package/dist/{connection-bf7811aa.d.ts → connection-64b9e0ff.d.ts} +1 -1
  8. package/dist/{connection-d880aa4a.d.ts → connection-a6cc48e8.d.ts} +1 -1
  9. package/dist/{index-0c0a69f6.d.ts → index-1afc5580.d.ts} +5 -9
  10. package/dist/router/index.cjs +1 -1
  11. package/dist/router/index.d.cts +1 -1
  12. package/dist/router/index.d.ts +1 -1
  13. package/dist/router/index.js +1 -1
  14. package/dist/transport/impls/stdio/client.cjs +39 -35
  15. package/dist/transport/impls/stdio/client.d.cts +2 -2
  16. package/dist/transport/impls/stdio/client.d.ts +2 -2
  17. package/dist/transport/impls/stdio/client.js +2 -2
  18. package/dist/transport/impls/stdio/server.cjs +38 -33
  19. package/dist/transport/impls/stdio/server.d.cts +2 -2
  20. package/dist/transport/impls/stdio/server.d.ts +2 -2
  21. package/dist/transport/impls/stdio/server.js +2 -2
  22. package/dist/transport/impls/uds/client.cjs +39 -35
  23. package/dist/transport/impls/uds/client.d.cts +2 -2
  24. package/dist/transport/impls/uds/client.d.ts +2 -2
  25. package/dist/transport/impls/uds/client.js +2 -2
  26. package/dist/transport/impls/uds/server.cjs +38 -33
  27. package/dist/transport/impls/uds/server.d.cts +2 -2
  28. package/dist/transport/impls/uds/server.d.ts +2 -2
  29. package/dist/transport/impls/uds/server.js +2 -2
  30. package/dist/transport/impls/ws/client.cjs +41 -36
  31. package/dist/transport/impls/ws/client.d.cts +2 -2
  32. package/dist/transport/impls/ws/client.d.ts +2 -2
  33. package/dist/transport/impls/ws/client.js +4 -3
  34. package/dist/transport/impls/ws/server.cjs +38 -33
  35. package/dist/transport/impls/ws/server.d.cts +2 -2
  36. package/dist/transport/impls/ws/server.d.ts +2 -2
  37. package/dist/transport/impls/ws/server.js +2 -2
  38. package/dist/transport/index.cjs +39 -35
  39. package/dist/transport/index.d.cts +1 -1
  40. package/dist/transport/index.d.ts +1 -1
  41. package/dist/transport/index.js +1 -1
  42. package/dist/util/testHelpers.d.cts +1 -1
  43. package/dist/util/testHelpers.d.ts +1 -1
  44. package/dist/util/testHelpers.js +1 -1
  45. package/package.json +1 -1
@@ -143,7 +143,7 @@ var Session = class {
143
143
  log?.info(
144
144
  `${this.from} -- closing connection (id: ${this.connection.debugId}) to ${this.to} due to inactivity`
145
145
  );
146
- this.halfCloseConnection();
146
+ this.closeStaleConnection(this.connection);
147
147
  }
148
148
  return;
149
149
  }
@@ -204,17 +204,27 @@ var Session = class {
204
204
  this.cancelGrace();
205
205
  this.connection = newConn;
206
206
  }
207
+ graceCb;
207
208
  beginGrace(cb) {
209
+ this.graceCb = cb;
208
210
  this.disconnectionGrace = setTimeout(() => {
209
- this.resetBufferedMessages();
210
- clearInterval(this.heartbeat);
211
+ this.close();
211
212
  cb();
212
213
  }, SESSION_DISCONNECT_GRACE_MS);
213
214
  }
215
+ // called on reconnect of the underlying session
214
216
  cancelGrace() {
215
217
  this.heartbeatMisses = 0;
216
218
  clearTimeout(this.disconnectionGrace);
217
219
  }
220
+ // closed when we want to discard the whole session
221
+ // (i.e. shutdown or session disconnect)
222
+ close() {
223
+ this.closeStaleConnection(this.connection);
224
+ this.cancelGrace();
225
+ clearInterval(this.heartbeat);
226
+ this.resetBufferedMessages();
227
+ }
218
228
  get connected() {
219
229
  return this.connection !== void 0;
220
230
  }
@@ -233,15 +243,6 @@ var Session = class {
233
243
  this.seq++;
234
244
  return msg;
235
245
  }
236
- /**
237
- * Closes the out-going connection but doesn't remove the listeners
238
- * for incoming messages. The connection will eventually call onClose
239
- * when it is ready to be cleaned up and only then will {@link connection} be set back
240
- * to undefined
241
- */
242
- halfCloseConnection() {
243
- this.connection?.close();
244
- }
245
246
  inspectSendBuffer() {
246
247
  return this.sendBuffer;
247
248
  }
@@ -332,19 +333,18 @@ var Transport = class {
332
333
  status: "connect",
333
334
  conn
334
335
  });
335
- let session = this.sessions.get(connectedTo);
336
+ let oldSession = this.sessions.get(connectedTo);
336
337
  const lastInstanceId = this.connectedInstanceIds.get(connectedTo);
337
- if (session && lastInstanceId !== instanceId && lastInstanceId !== void 0) {
338
- log?.debug(
339
- `${this.clientId} -- handshake from ${connectedTo} has different server instance (got: ${instanceId}, last connected to: ${lastInstanceId}), starting a new session`
338
+ if (oldSession && lastInstanceId !== void 0 && lastInstanceId !== instanceId) {
339
+ log?.warn(
340
+ `${this.clientId} -- handshake from ${connectedTo} is a different instance (got: ${instanceId}, last connected to: ${lastInstanceId}), starting a new session`
340
341
  );
341
- session.resetBufferedMessages();
342
- session.closeStaleConnection();
343
- this.deleteSession(session);
344
- session = void 0;
342
+ oldSession.close();
343
+ this.deleteSession(oldSession);
344
+ oldSession = void 0;
345
345
  }
346
346
  this.connectedInstanceIds.set(connectedTo, instanceId);
347
- if (session === void 0) {
347
+ if (oldSession === void 0) {
348
348
  const newSession = this.createSession(connectedTo, conn);
349
349
  log?.info(
350
350
  `${this.clientId} -- new connection (id: ${conn.debugId}) for new session (id: ${newSession.debugId}) to ${connectedTo}`
@@ -352,11 +352,11 @@ var Transport = class {
352
352
  return newSession;
353
353
  }
354
354
  log?.info(
355
- `${this.clientId} -- new connection (id: ${conn.debugId}) for existing session (id: ${session.debugId}) to ${connectedTo}`
355
+ `${this.clientId} -- new connection (id: ${conn.debugId}) for existing session (id: ${oldSession.debugId}) to ${connectedTo}`
356
356
  );
357
- session.replaceWithNewConnection(conn);
358
- session.sendBufferedMessages();
359
- return session;
357
+ oldSession.replaceWithNewConnection(conn);
358
+ oldSession.sendBufferedMessages();
359
+ return oldSession;
360
360
  }
361
361
  createSession(connectedTo, conn) {
362
362
  const session = new Session(
@@ -374,24 +374,25 @@ var Transport = class {
374
374
  }
375
375
  deleteSession(session) {
376
376
  this.sessions.delete(session.to);
377
+ log?.info(
378
+ `${this.clientId} -- session ${session.debugId} disconnect from ${session.to}`
379
+ );
377
380
  this.eventDispatcher.dispatchEvent("sessionStatus", {
378
381
  status: "disconnect",
379
382
  session
380
383
  });
381
- log?.info(
382
- `${this.clientId} -- session ${session.debugId} disconnect from ${session.to}`
383
- );
384
384
  }
385
385
  /**
386
386
  * The downstream implementation needs to call this when a connection is closed.
387
387
  * @param conn The connection object.
388
+ * @param connectedTo The peer we are connected to.
388
389
  */
389
390
  onDisconnect(conn, connectedTo) {
390
391
  this.eventDispatcher.dispatchEvent("connectionStatus", {
391
392
  status: "disconnect",
392
393
  conn
393
394
  });
394
- if (!connectedTo)
395
+ if (this.state !== "open")
395
396
  return;
396
397
  const session = this.sessionByClientId(connectedTo);
397
398
  log?.info(
@@ -434,6 +435,8 @@ var Transport = class {
434
435
  * @param msg The received message.
435
436
  */
436
437
  handleMsg(msg) {
438
+ if (this.state !== "open")
439
+ return;
437
440
  const session = this.sessionByClientId(msg.from);
438
441
  session.cancelGrace();
439
442
  log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
@@ -510,10 +513,11 @@ var Transport = class {
510
513
  * Closes the transport. Any messages sent while the transport is closed will be silently discarded.
511
514
  */
512
515
  close() {
516
+ this.state = "closed";
513
517
  for (const session of this.sessions.values()) {
514
- session.halfCloseConnection();
518
+ session.close();
519
+ this.deleteSession(session);
515
520
  }
516
- this.state = "closed";
517
521
  log?.info(`${this.clientId} -- manually closed transport`);
518
522
  }
519
523
  /**
@@ -522,10 +526,11 @@ var Transport = class {
522
526
  * Destroys the transport. Any messages sent while the transport is destroyed will throw an error.
523
527
  */
524
528
  destroy() {
529
+ this.state = "destroyed";
525
530
  for (const session of this.sessions.values()) {
526
- session.closeStaleConnection(session.connection);
531
+ session.close();
532
+ this.deleteSession(session);
527
533
  }
528
- this.state = "destroyed";
529
534
  log?.info(`${this.clientId} -- manually destroyed transport`);
530
535
  }
531
536
  };
@@ -631,8 +636,7 @@ var ClientTransport = class extends Transport {
631
636
  return bootHandler;
632
637
  }
633
638
  onDisconnect(conn, connectedTo) {
634
- if (connectedTo)
635
- this.inflightConnectionPromises.delete(connectedTo);
639
+ this.inflightConnectionPromises.delete(connectedTo);
636
640
  super.onDisconnect(conn, connectedTo);
637
641
  }
638
642
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Connection
3
- } from "./chunk-QEYN2Z6O.js";
3
+ } from "./chunk-2PKONGC3.js";
4
4
 
5
5
  // transport/impls/ws/connection.ts
6
6
  var WebSocketConnection = class extends Connection {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-IIBVKYDB.js";
4
4
  import {
5
5
  Connection
6
- } from "./chunk-QEYN2Z6O.js";
6
+ } from "./chunk-2PKONGC3.js";
7
7
 
8
8
  // transport/impls/uds/connection.ts
9
9
  var UdsConnection = class extends Connection {
@@ -756,7 +756,7 @@ var RiverServer = class {
756
756
  }
757
757
  const disconnectedClientId = evt.session.to;
758
758
  log?.info(
759
- `${this.transport.clientId} -- got unexpected disconnect from ${disconnectedClientId}, cleaning up streams`
759
+ `${this.transport.clientId} -- got session disconnect from ${disconnectedClientId}, cleaning up streams`
760
760
  );
761
761
  const streamsFromThisClient = this.clientStreams.get(disconnectedClientId);
762
762
  if (!streamsFromThisClient) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-IIBVKYDB.js";
4
4
  import {
5
5
  Connection
6
- } from "./chunk-QEYN2Z6O.js";
6
+ } from "./chunk-2PKONGC3.js";
7
7
 
8
8
  // transport/impls/stdio/connection.ts
9
9
  var StreamConnection = class extends Connection {
@@ -1,5 +1,5 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { C as Connection } from './index-0c0a69f6.js';
2
+ import { C as Connection } from './index-1afc5580.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-0c0a69f6.js';
1
+ import { C as Connection } from './index-1afc5580.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-0c0a69f6.js';
1
+ import { C as Connection } from './index-1afc5580.js';
2
2
  import { Socket } from 'node:net';
3
3
  import { U as Uint32LengthPrefixFraming } from './messageFraming-b200ef25.js';
4
4
 
@@ -214,18 +214,13 @@ 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;
217
218
  beginGrace(cb: () => void): void;
218
219
  cancelGrace(): void;
220
+ close(): void;
219
221
  get connected(): boolean;
220
222
  get nextExpectedSeq(): number;
221
223
  constructMsg<Payload extends Record<string, unknown>>(partialMsg: PartialTransportMessage<Payload>): TransportMessage<Payload>;
222
- /**
223
- * Closes the out-going connection but doesn't remove the listeners
224
- * for incoming messages. The connection will eventually call onClose
225
- * when it is ready to be cleaned up and only then will {@link connection} be set back
226
- * to undefined
227
- */
228
- halfCloseConnection(): void;
229
224
  inspectSendBuffer(): ReadonlyArray<OpaqueTransportMessage>;
230
225
  }
231
226
 
@@ -359,8 +354,9 @@ declare abstract class Transport<ConnType extends Connection> {
359
354
  /**
360
355
  * The downstream implementation needs to call this when a connection is closed.
361
356
  * @param conn The connection object.
357
+ * @param connectedTo The peer we are connected to.
362
358
  */
363
- onDisconnect(conn: ConnType, connectedTo: TransportClientId | undefined): void;
359
+ onDisconnect(conn: ConnType, connectedTo: TransportClientId): void;
364
360
  /**
365
361
  * Parses a message from a Uint8Array into a {@link OpaqueTransportMessage}.
366
362
  * @param msg The message to parse.
@@ -429,7 +425,7 @@ declare abstract class ClientTransport<ConnType extends Connection> extends Tran
429
425
  */
430
426
  connect(to: TransportClientId, attempt?: number): Promise<void>;
431
427
  receiveWithBootSequence(conn: ConnType, sessionCb: (sess: Session<ConnType>) => void): (data: Uint8Array) => void;
432
- onDisconnect(conn: ConnType, connectedTo: string | undefined): void;
428
+ onDisconnect(conn: ConnType, connectedTo: string): void;
433
429
  }
434
430
  declare abstract class ServerTransport<ConnType extends Connection> extends Transport<ConnType> {
435
431
  constructor(clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
@@ -853,7 +853,7 @@ var RiverServer = class {
853
853
  }
854
854
  const disconnectedClientId = evt.session.to;
855
855
  log?.info(
856
- `${this.transport.clientId} -- got unexpected disconnect from ${disconnectedClientId}, cleaning up streams`
856
+ `${this.transport.clientId} -- got session disconnect from ${disconnectedClientId}, cleaning up streams`
857
857
  );
858
858
  const streamsFromThisClient = this.clientStreams.get(disconnectedClientId);
859
859
  if (!streamsFromThisClient) {
@@ -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-0c0a69f6.js';
3
+ import { T as Transport, C as Connection, b as TransportClientId } from '../index-1afc5580.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-0c0a69f6.js';
3
+ import { T as Transport, C as Connection, b as TransportClientId } from '../index-1afc5580.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-55XUAPC6.js";
11
+ } from "../chunk-AFLZ6INU.js";
12
12
  import "../chunk-XFFS4UOD.js";
13
13
  import "../chunk-H4BYJELI.js";
14
14
  export {
@@ -227,7 +227,7 @@ var Session = class {
227
227
  log?.info(
228
228
  `${this.from} -- closing connection (id: ${this.connection.debugId}) to ${this.to} due to inactivity`
229
229
  );
230
- this.halfCloseConnection();
230
+ this.closeStaleConnection(this.connection);
231
231
  }
232
232
  return;
233
233
  }
@@ -288,17 +288,27 @@ var Session = class {
288
288
  this.cancelGrace();
289
289
  this.connection = newConn;
290
290
  }
291
+ graceCb;
291
292
  beginGrace(cb) {
293
+ this.graceCb = cb;
292
294
  this.disconnectionGrace = setTimeout(() => {
293
- this.resetBufferedMessages();
294
- clearInterval(this.heartbeat);
295
+ this.close();
295
296
  cb();
296
297
  }, SESSION_DISCONNECT_GRACE_MS);
297
298
  }
299
+ // called on reconnect of the underlying session
298
300
  cancelGrace() {
299
301
  this.heartbeatMisses = 0;
300
302
  clearTimeout(this.disconnectionGrace);
301
303
  }
304
+ // closed when we want to discard the whole session
305
+ // (i.e. shutdown or session disconnect)
306
+ close() {
307
+ this.closeStaleConnection(this.connection);
308
+ this.cancelGrace();
309
+ clearInterval(this.heartbeat);
310
+ this.resetBufferedMessages();
311
+ }
302
312
  get connected() {
303
313
  return this.connection !== void 0;
304
314
  }
@@ -317,15 +327,6 @@ var Session = class {
317
327
  this.seq++;
318
328
  return msg;
319
329
  }
320
- /**
321
- * Closes the out-going connection but doesn't remove the listeners
322
- * for incoming messages. The connection will eventually call onClose
323
- * when it is ready to be cleaned up and only then will {@link connection} be set back
324
- * to undefined
325
- */
326
- halfCloseConnection() {
327
- this.connection?.close();
328
- }
329
330
  inspectSendBuffer() {
330
331
  return this.sendBuffer;
331
332
  }
@@ -477,19 +478,18 @@ var Transport = class {
477
478
  status: "connect",
478
479
  conn
479
480
  });
480
- let session = this.sessions.get(connectedTo);
481
+ let oldSession = this.sessions.get(connectedTo);
481
482
  const lastInstanceId = this.connectedInstanceIds.get(connectedTo);
482
- if (session && lastInstanceId !== instanceId && lastInstanceId !== void 0) {
483
- log?.debug(
484
- `${this.clientId} -- handshake from ${connectedTo} has different server instance (got: ${instanceId}, last connected to: ${lastInstanceId}), starting a new session`
483
+ if (oldSession && lastInstanceId !== void 0 && lastInstanceId !== instanceId) {
484
+ log?.warn(
485
+ `${this.clientId} -- handshake from ${connectedTo} is a different instance (got: ${instanceId}, last connected to: ${lastInstanceId}), starting a new session`
485
486
  );
486
- session.resetBufferedMessages();
487
- session.closeStaleConnection();
488
- this.deleteSession(session);
489
- session = void 0;
487
+ oldSession.close();
488
+ this.deleteSession(oldSession);
489
+ oldSession = void 0;
490
490
  }
491
491
  this.connectedInstanceIds.set(connectedTo, instanceId);
492
- if (session === void 0) {
492
+ if (oldSession === void 0) {
493
493
  const newSession = this.createSession(connectedTo, conn);
494
494
  log?.info(
495
495
  `${this.clientId} -- new connection (id: ${conn.debugId}) for new session (id: ${newSession.debugId}) to ${connectedTo}`
@@ -497,11 +497,11 @@ var Transport = class {
497
497
  return newSession;
498
498
  }
499
499
  log?.info(
500
- `${this.clientId} -- new connection (id: ${conn.debugId}) for existing session (id: ${session.debugId}) to ${connectedTo}`
500
+ `${this.clientId} -- new connection (id: ${conn.debugId}) for existing session (id: ${oldSession.debugId}) to ${connectedTo}`
501
501
  );
502
- session.replaceWithNewConnection(conn);
503
- session.sendBufferedMessages();
504
- return session;
502
+ oldSession.replaceWithNewConnection(conn);
503
+ oldSession.sendBufferedMessages();
504
+ return oldSession;
505
505
  }
506
506
  createSession(connectedTo, conn) {
507
507
  const session = new Session(
@@ -519,24 +519,25 @@ var Transport = class {
519
519
  }
520
520
  deleteSession(session) {
521
521
  this.sessions.delete(session.to);
522
+ log?.info(
523
+ `${this.clientId} -- session ${session.debugId} disconnect from ${session.to}`
524
+ );
522
525
  this.eventDispatcher.dispatchEvent("sessionStatus", {
523
526
  status: "disconnect",
524
527
  session
525
528
  });
526
- log?.info(
527
- `${this.clientId} -- session ${session.debugId} disconnect from ${session.to}`
528
- );
529
529
  }
530
530
  /**
531
531
  * The downstream implementation needs to call this when a connection is closed.
532
532
  * @param conn The connection object.
533
+ * @param connectedTo The peer we are connected to.
533
534
  */
534
535
  onDisconnect(conn, connectedTo) {
535
536
  this.eventDispatcher.dispatchEvent("connectionStatus", {
536
537
  status: "disconnect",
537
538
  conn
538
539
  });
539
- if (!connectedTo)
540
+ if (this.state !== "open")
540
541
  return;
541
542
  const session = this.sessionByClientId(connectedTo);
542
543
  log?.info(
@@ -579,6 +580,8 @@ var Transport = class {
579
580
  * @param msg The received message.
580
581
  */
581
582
  handleMsg(msg) {
583
+ if (this.state !== "open")
584
+ return;
582
585
  const session = this.sessionByClientId(msg.from);
583
586
  session.cancelGrace();
584
587
  log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
@@ -655,10 +658,11 @@ var Transport = class {
655
658
  * Closes the transport. Any messages sent while the transport is closed will be silently discarded.
656
659
  */
657
660
  close() {
661
+ this.state = "closed";
658
662
  for (const session of this.sessions.values()) {
659
- session.halfCloseConnection();
663
+ session.close();
664
+ this.deleteSession(session);
660
665
  }
661
- this.state = "closed";
662
666
  log?.info(`${this.clientId} -- manually closed transport`);
663
667
  }
664
668
  /**
@@ -667,10 +671,11 @@ var Transport = class {
667
671
  * Destroys the transport. Any messages sent while the transport is destroyed will throw an error.
668
672
  */
669
673
  destroy() {
674
+ this.state = "destroyed";
670
675
  for (const session of this.sessions.values()) {
671
- session.closeStaleConnection(session.connection);
676
+ session.close();
677
+ this.deleteSession(session);
672
678
  }
673
- this.state = "destroyed";
674
679
  log?.info(`${this.clientId} -- manually destroyed transport`);
675
680
  }
676
681
  };
@@ -776,8 +781,7 @@ var ClientTransport = class extends Transport {
776
781
  return bootHandler;
777
782
  }
778
783
  onDisconnect(conn, connectedTo) {
779
- if (connectedTo)
780
- this.inflightConnectionPromises.delete(connectedTo);
784
+ this.inflightConnectionPromises.delete(connectedTo);
781
785
  super.onDisconnect(conn, connectedTo);
782
786
  }
783
787
  };
@@ -1,5 +1,5 @@
1
- import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-0c0a69f6.js';
2
- import { S as StreamConnection } from '../../../connection-bf7811aa.js';
1
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-1afc5580.js';
2
+ import { S as StreamConnection } from '../../../connection-64b9e0ff.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-0c0a69f6.js';
2
- import { S as StreamConnection } from '../../../connection-bf7811aa.js';
1
+ import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-1afc5580.js';
2
+ import { S as StreamConnection } from '../../../connection-64b9e0ff.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-M6LY25P2.js";
3
+ } from "../../../chunk-H4QR2K3T.js";
4
4
  import "../../../chunk-5IZ2UHWV.js";
5
5
  import "../../../chunk-IIBVKYDB.js";
6
6
  import {
7
7
  ClientTransport
8
- } from "../../../chunk-QEYN2Z6O.js";
8
+ } from "../../../chunk-2PKONGC3.js";
9
9
  import "../../../chunk-GZ7HCLLM.js";
10
10
  import "../../../chunk-XFFS4UOD.js";
11
11
  import {