@replit/river 0.26.2 → 0.26.4

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 (52) hide show
  1. package/dist/{chunk-NC54BC47.js → chunk-42SXIIHP.js} +45 -17
  2. package/dist/chunk-42SXIIHP.js.map +1 -0
  3. package/dist/{chunk-M75K5TJS.js → chunk-65EMTMCV.js} +2 -2
  4. package/dist/{chunk-M75K5TJS.js.map → chunk-65EMTMCV.js.map} +1 -1
  5. package/dist/{chunk-AWCUCZY4.js → chunk-CYD6GTCU.js} +2 -2
  6. package/dist/{chunk-YQABPD3C.js → chunk-DS5LF6PS.js} +51 -56
  7. package/dist/chunk-DS5LF6PS.js.map +1 -0
  8. package/dist/{chunk-IV27BICV.js → chunk-HPOR6FST.js} +30 -31
  9. package/dist/chunk-HPOR6FST.js.map +1 -0
  10. package/dist/{chunk-MREEJE3X.js → chunk-PXRKBNWN.js} +2 -2
  11. package/dist/{chunk-M5X4JTU3.js → chunk-RSCUADHY.js} +5 -4
  12. package/dist/{chunk-M5X4JTU3.js.map → chunk-RSCUADHY.js.map} +1 -1
  13. package/dist/{client-654098be.d.ts → client-6c67339a.d.ts} +3 -3
  14. package/dist/{connection-bc2454dc.d.ts → connection-03ffb583.d.ts} +1 -1
  15. package/dist/{handshake-1a86f06d.d.ts → handshake-154a0bb2.d.ts} +30 -1
  16. package/dist/logging/index.d.cts +1 -1
  17. package/dist/logging/index.d.ts +1 -1
  18. package/dist/{message-57296605.d.ts → message-ff78a233.d.ts} +1 -1
  19. package/dist/router/index.cjs +1 -1
  20. package/dist/router/index.cjs.map +1 -1
  21. package/dist/router/index.d.cts +9 -8
  22. package/dist/router/index.d.ts +9 -8
  23. package/dist/router/index.js +2 -2
  24. package/dist/{server-9a6b5a8e.d.ts → server-1f5eb427.d.ts} +17 -4
  25. package/dist/{services-7daa60a0.d.ts → services-6140f578.d.ts} +3 -3
  26. package/dist/transport/impls/ws/client.cjs +75 -46
  27. package/dist/transport/impls/ws/client.cjs.map +1 -1
  28. package/dist/transport/impls/ws/client.d.cts +5 -4
  29. package/dist/transport/impls/ws/client.d.ts +5 -4
  30. package/dist/transport/impls/ws/client.js +8 -7
  31. package/dist/transport/impls/ws/client.js.map +1 -1
  32. package/dist/transport/impls/ws/server.cjs +93 -69
  33. package/dist/transport/impls/ws/server.cjs.map +1 -1
  34. package/dist/transport/impls/ws/server.d.cts +5 -4
  35. package/dist/transport/impls/ws/server.d.ts +5 -4
  36. package/dist/transport/impls/ws/server.js +5 -5
  37. package/dist/transport/index.cjs +119 -96
  38. package/dist/transport/index.cjs.map +1 -1
  39. package/dist/transport/index.d.cts +5 -4
  40. package/dist/transport/index.d.ts +5 -4
  41. package/dist/transport/index.js +5 -5
  42. package/dist/util/testHelpers.cjs +44 -16
  43. package/dist/util/testHelpers.cjs.map +1 -1
  44. package/dist/util/testHelpers.d.cts +5 -4
  45. package/dist/util/testHelpers.d.ts +5 -4
  46. package/dist/util/testHelpers.js +3 -3
  47. package/package.json +1 -1
  48. package/dist/chunk-IV27BICV.js.map +0 -1
  49. package/dist/chunk-NC54BC47.js.map +0 -1
  50. package/dist/chunk-YQABPD3C.js.map +0 -1
  51. /package/dist/{chunk-AWCUCZY4.js.map → chunk-CYD6GTCU.js.map} +0 -0
  52. /package/dist/{chunk-MREEJE3X.js.map → chunk-PXRKBNWN.js.map} +0 -0
@@ -1,14 +1,15 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-7daa60a0.js';
2
- export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-7daa60a0.js';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-6140f578.js';
2
+ export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-6140f578.js';
3
3
  import { Static } from '@sinclair/typebox';
4
4
  import { Pushable } from 'it-pushable';
5
- import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-1a86f06d.js';
6
- export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-1a86f06d.js';
7
- import { S as ServerTransport } from '../server-9a6b5a8e.js';
8
- import '../message-57296605.js';
5
+ import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-154a0bb2.js';
6
+ export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-154a0bb2.js';
7
+ import { S as ServerTransport } from '../server-1f5eb427.js';
8
+ import '../message-ff78a233.js';
9
9
  import '@sinclair/typebox/value';
10
10
  import '@opentelemetry/api';
11
- import '../client-654098be.js';
11
+ import '../client-6c67339a.js';
12
+ import '@sinclair/typebox/errors';
12
13
  import '../types-3e5768ec.js';
13
14
 
14
15
  /**
@@ -45,6 +46,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
45
46
  extendedContext?: Omit<ServiceContext, 'state'>;
46
47
  }>): Server<Services>;
47
48
 
48
- var version = "0.26.2";
49
+ var version = "0.26.4";
49
50
 
50
51
  export { PayloadType, version as RIVER_VERSION, Result, RiverError, Server, ServiceContext, createServer };
@@ -1,14 +1,15 @@
1
- import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-7daa60a0.js';
2
- export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-7daa60a0.js';
1
+ import { A as AnyServiceSchemaMap, I as InstantiatedServiceSchemaMap, P as PayloadType, b as Result, R as RiverError } from '../services-6140f578.js';
2
+ export { C as Client, E as Err, O as Ok, z as Output, j as ProcErrors, f as ProcHandler, g as ProcInit, h as ProcInput, i as ProcOutput, k as ProcType, a as Procedure, p as ProcedureMap, d as ProcedureResult, q as RPCProcedure, y as ResultUnwrapErr, x as ResultUnwrapOk, w as RiverErrorSchema, c as RiverUncaughtSchema, o as SerializedProcedureSchema, m as SerializedServerSchema, n as SerializedServiceSchema, S as Service, e as ServiceConfiguration, l as ServiceSchema, t as StreamProcedure, r as SubscriptionProcedure, v as UNCAUGHT_ERROR, U as UploadProcedure, V as ValidProcType, u as createClient, s as serializeSchema } from '../services-6140f578.js';
3
3
  import { Static } from '@sinclair/typebox';
4
4
  import { Pushable } from 'it-pushable';
5
- import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-1a86f06d.js';
6
- export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-1a86f06d.js';
7
- import { S as ServerTransport } from '../server-9a6b5a8e.js';
8
- import '../message-57296605.js';
5
+ import { C as Connection, s as ServerHandshakeOptions, o as ServiceContext } from '../handshake-154a0bb2.js';
6
+ export { t as ParsedMetadata, u as ServiceContextWithState, v as ServiceContextWithTransportInfo, w as createClientHandshakeOptions, x as createServerHandshakeOptions } from '../handshake-154a0bb2.js';
7
+ import { S as ServerTransport } from '../server-1f5eb427.js';
8
+ import '../message-ff78a233.js';
9
9
  import '@sinclair/typebox/value';
10
10
  import '@opentelemetry/api';
11
- import '../client-654098be.js';
11
+ import '../client-6c67339a.js';
12
+ import '@sinclair/typebox/errors';
12
13
  import '../types-3e5768ec.js';
13
14
 
14
15
  /**
@@ -45,6 +46,6 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
45
46
  extendedContext?: Omit<ServiceContext, 'state'>;
46
47
  }>): Server<Services>;
47
48
 
48
- var version = "0.26.2";
49
+ var version = "0.26.4";
49
50
 
50
51
  export { PayloadType, version as RIVER_VERSION, Result, RiverError, Server, ServiceContext, createServer };
@@ -10,10 +10,10 @@ import {
10
10
  createServer,
11
11
  createServerHandshakeOptions,
12
12
  serializeSchema
13
- } from "../chunk-MREEJE3X.js";
13
+ } from "../chunk-PXRKBNWN.js";
14
14
  import {
15
15
  version
16
- } from "../chunk-M75K5TJS.js";
16
+ } from "../chunk-65EMTMCV.js";
17
17
  export {
18
18
  Err,
19
19
  Ok,
@@ -1,5 +1,6 @@
1
- import { C as Connection, y as CommonSession, d as SessionState, z as CommonSessionProps, T as Transport, A as ServerTransportOptions, s as ServerHandshakeOptions, t as ParsedMetadata, B as ServerSession, c as ProvidedServerTransportOptions } from './handshake-1a86f06d.js';
2
- import { M as MessageMetadata, a as TransportMessage, b as OpaqueTransportMessage, H as HandshakeErrorResponseCodes, c as TransportClientId, P as PartialTransportMessage } from './message-57296605.js';
1
+ import { C as Connection, y as CommonSession, d as SessionState, z as CommonSessionProps, T as Transport, A as ServerTransportOptions, s as ServerHandshakeOptions, t as ParsedMetadata, B as ServerSession, c as ProvidedServerTransportOptions } from './handshake-154a0bb2.js';
2
+ import { b as OpaqueTransportMessage, e as Tags, a as TransportMessage, H as HandshakeErrorResponseCodes, c as TransportClientId, P as PartialTransportMessage } from './message-ff78a233.js';
3
+ import * as _sinclair_typebox_errors from '@sinclair/typebox/errors';
3
4
  import { Static } from '@sinclair/typebox';
4
5
 
5
6
  interface SessionWaitingForHandshakeListeners {
@@ -19,8 +20,21 @@ declare class SessionWaitingForHandshake<ConnType extends Connection> extends Co
19
20
  listeners: SessionWaitingForHandshakeListeners;
20
21
  handshakeTimeout?: ReturnType<typeof setTimeout>;
21
22
  constructor(props: SessionWaitingForHandshakeProps<ConnType>);
23
+ get loggingMetadata(): {
24
+ protocolVersion?: string | undefined;
25
+ clientId: string;
26
+ connectedTo?: string | undefined;
27
+ sessionId?: string | undefined;
28
+ connId: string;
29
+ transportMessage?: Partial<OpaqueTransportMessage> | undefined;
30
+ validationErrors?: _sinclair_typebox_errors.ValueError[] | undefined;
31
+ tags?: Tags[] | undefined;
32
+ telemetry?: {
33
+ traceId: string;
34
+ spanId: string;
35
+ } | undefined;
36
+ };
22
37
  onHandshakeData: (msg: Uint8Array) => void;
23
- get loggingMetadata(): MessageMetadata;
24
38
  sendHandshake(msg: TransportMessage): boolean;
25
39
  _handleStateExit(): void;
26
40
  _handleClose(): void;
@@ -49,7 +63,6 @@ declare abstract class ServerTransport<ConnType extends Connection> extends Tran
49
63
  protected handleConnection(conn: ConnType): void;
50
64
  private rejectHandshakeRequest;
51
65
  protected onHandshakeRequest(session: SessionWaitingForHandshake<ConnType>, msg: OpaqueTransportMessage): Promise<void>;
52
- private validateHandshakeMetadata;
53
66
  }
54
67
 
55
68
  export { ServerTransport as S, SessionWaitingForHandshake as a };
@@ -1,8 +1,8 @@
1
1
  import { Static, TObject, TUnion, TString, TSchema, TNever, TLiteral } from '@sinclair/typebox';
2
2
  import { Pushable } from 'it-pushable';
3
- import { C as Connection, p as ClientHandshakeOptions, v as ServiceContextWithTransportInfo, o as ServiceContext } from './handshake-1a86f06d.js';
4
- import { c as TransportClientId } from './message-57296605.js';
5
- import { C as ClientTransport } from './client-654098be.js';
3
+ import { C as Connection, p as ClientHandshakeOptions, v as ServiceContextWithTransportInfo, o as ServiceContext } from './handshake-154a0bb2.js';
4
+ import { c as TransportClientId } from './message-ff78a233.js';
5
+ import { C as ClientTransport } from './client-6c67339a.js';
6
6
 
7
7
  type AsyncIter<T> = AsyncGenerator<T, T>;
8
8
  /**
@@ -420,6 +420,7 @@ var StateMachineState = class {
420
420
  }
421
421
  if (prop === "_handleClose") {
422
422
  return () => {
423
+ target._isConsumed = true;
423
424
  target._handleStateExit();
424
425
  target._handleClose();
425
426
  };
@@ -500,15 +501,18 @@ var IdentifiedSession = class extends CommonSession {
500
501
  }
501
502
  get loggingMetadata() {
502
503
  const spanContext = this.telemetry.span.spanContext();
503
- return {
504
+ const metadata = {
504
505
  clientId: this.from,
505
506
  connectedTo: this.to,
506
- sessionId: this.id,
507
- telemetry: {
507
+ sessionId: this.id
508
+ };
509
+ if (this.telemetry.span.isRecording()) {
510
+ metadata.telemetry = {
508
511
  traceId: spanContext.traceId,
509
512
  spanId: spanContext.spanId
510
- }
511
- };
513
+ };
514
+ }
515
+ return metadata;
512
516
  }
513
517
  constructMsg(partialMsg) {
514
518
  const msg = {
@@ -571,9 +575,6 @@ var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
571
575
  super(props);
572
576
  this.connPromise = props.connPromise;
573
577
  this.listeners = props.listeners;
574
- this.connectionTimeout = setTimeout(() => {
575
- this.listeners.onConnectionTimeout();
576
- }, this.options.connectionTimeoutMs);
577
578
  this.connPromise.then(
578
579
  (conn) => {
579
580
  if (this._isConsumed)
@@ -586,11 +587,25 @@ var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
586
587
  this.listeners.onConnectionFailed(err);
587
588
  }
588
589
  );
590
+ this.connectionTimeout = setTimeout(() => {
591
+ this.listeners.onConnectionTimeout();
592
+ }, this.options.connectionTimeoutMs);
589
593
  }
590
594
  // close a pending connection if it resolves, ignore errors if the promise
591
595
  // ends up rejected anyways
592
596
  bestEffortClose() {
593
- void this.connPromise.then((conn) => conn.close()).catch(() => {
597
+ const logger = this.log;
598
+ const metadata = this.loggingMetadata;
599
+ this.connPromise.then((conn) => {
600
+ conn.close();
601
+ logger?.info(
602
+ "connection eventually resolved but session has transitioned, closed connection",
603
+ {
604
+ ...metadata,
605
+ ...conn.loggingMetadata
606
+ }
607
+ );
608
+ }).catch(() => {
594
609
  });
595
610
  }
596
611
  _handleStateExit() {
@@ -621,7 +636,7 @@ var SessionNoConnection = class extends IdentifiedSessionWithGracePeriod {
621
636
  var import_api = require("@opentelemetry/api");
622
637
 
623
638
  // package.json
624
- var version = "0.26.2";
639
+ var version = "0.26.4";
625
640
 
626
641
  // tracing/index.ts
627
642
  function getPropagationContext(ctx) {
@@ -669,6 +684,13 @@ var SessionWaitingForHandshake = class extends CommonSession {
669
684
  this.conn.addErrorListener(this.listeners.onConnectionErrored);
670
685
  this.conn.addCloseListener(this.listeners.onConnectionClosed);
671
686
  }
687
+ get loggingMetadata() {
688
+ return {
689
+ clientId: this.from,
690
+ connId: this.conn.id,
691
+ ...this.conn.loggingMetadata
692
+ };
693
+ }
672
694
  onHandshakeData = (msg) => {
673
695
  const parsedMsg = this.parseMsg(msg);
674
696
  if (parsedMsg === null) {
@@ -680,12 +702,6 @@ var SessionWaitingForHandshake = class extends CommonSession {
680
702
  }
681
703
  this.listeners.onHandshake(parsedMsg);
682
704
  };
683
- get loggingMetadata() {
684
- return {
685
- clientId: this.from,
686
- connId: this.conn.id
687
- };
688
- }
689
705
  sendHandshake(msg) {
690
706
  return this.conn.send(this.options.codec.toBuffer(msg));
691
707
  }
@@ -718,6 +734,12 @@ var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
718
734
  this.conn.addErrorListener(this.listeners.onConnectionErrored);
719
735
  this.conn.addCloseListener(this.listeners.onConnectionClosed);
720
736
  }
737
+ get loggingMetadata() {
738
+ return {
739
+ ...super.loggingMetadata,
740
+ ...this.conn.loggingMetadata
741
+ };
742
+ }
721
743
  onHandshakeData = (msg) => {
722
744
  const parsedMsg = this.parseMsg(msg);
723
745
  if (parsedMsg === null) {
@@ -805,6 +827,12 @@ var SessionConnected = class extends IdentifiedSession {
805
827
  this.heartbeatMisses++;
806
828
  }, this.options.heartbeatIntervalMs);
807
829
  }
830
+ get loggingMetadata() {
831
+ return {
832
+ ...super.loggingMetadata,
833
+ ...this.conn.loggingMetadata
834
+ };
835
+ }
808
836
  startActiveHeartbeat() {
809
837
  this.isActivelyHeartbeating = true;
810
838
  }
@@ -1306,8 +1334,9 @@ var Transport = class {
1306
1334
  status: "disconnect",
1307
1335
  session
1308
1336
  });
1337
+ const to = session.to;
1309
1338
  session.close();
1310
- this.sessions.delete(session.to);
1339
+ this.sessions.delete(to);
1311
1340
  }
1312
1341
  // common listeners
1313
1342
  onSessionGracePeriodElapsed(session) {
@@ -1511,14 +1540,14 @@ var ClientTransport = class extends Transport {
1511
1540
  msg.payload.status.code
1512
1541
  ) : false;
1513
1542
  const reason = `handshake failed: ${msg.payload.status.reason}`;
1543
+ const to = session.to;
1514
1544
  this.rejectHandshakeResponse(session, reason, {
1515
1545
  ...session.loggingMetadata,
1516
1546
  transportMessage: msg
1517
1547
  });
1518
1548
  if (retriable) {
1519
- this.tryReconnecting(session.to);
1549
+ this.tryReconnecting(to);
1520
1550
  } else {
1521
- this.deleteSession(session);
1522
1551
  this.protocolError({
1523
1552
  type: ProtocolError.HandshakeFailed,
1524
1553
  code: msg.payload.status.code,
@@ -1571,6 +1600,12 @@ var ClientTransport = class extends Transport {
1571
1600
  * @param to The client ID of the node to connect to.
1572
1601
  */
1573
1602
  connect(to) {
1603
+ if (this.getStatus() !== "open") {
1604
+ this.log?.info(
1605
+ `transport state is no longer open, cancelling attempt to connect to ${to}`
1606
+ );
1607
+ return;
1608
+ }
1574
1609
  let session = this.sessions.get(to);
1575
1610
  session ??= this.createUnconnectedSession(to);
1576
1611
  if (session.state !== "NoConnection" /* NoConnection */) {
@@ -1580,13 +1615,6 @@ var ClientTransport = class extends Transport {
1580
1615
  );
1581
1616
  return;
1582
1617
  }
1583
- if (this.getStatus() !== "open") {
1584
- this.log?.info(
1585
- `transport state is no longer open, cancelling attempt to connect to ${to}`,
1586
- session.loggingMetadata
1587
- );
1588
- return;
1589
- }
1590
1618
  if (!this.retryBudget.hasBudget()) {
1591
1619
  const budgetConsumed = this.retryBudget.getBudgetConsumed();
1592
1620
  const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
@@ -1608,22 +1636,7 @@ var ClientTransport = class extends Transport {
1608
1636
  backoffMs,
1609
1637
  {
1610
1638
  onBackoffFinished: () => {
1611
- const reconnectPromise = tracing_default.startActiveSpan(
1612
- "connect",
1613
- async (span) => {
1614
- try {
1615
- return await this.createNewOutgoingConnection(to);
1616
- } catch (err) {
1617
- const errStr = coerceErrorString(err);
1618
- span.recordException(errStr);
1619
- span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
1620
- throw err;
1621
- } finally {
1622
- span.end();
1623
- }
1624
- }
1625
- );
1626
- this.onBackoffFinished(backingOffSession, reconnectPromise);
1639
+ this.onBackoffFinished(backingOffSession);
1627
1640
  },
1628
1641
  onSessionGracePeriodElapsed: () => {
1629
1642
  this.onSessionGracePeriodElapsed(backingOffSession);
@@ -1632,7 +1645,19 @@ var ClientTransport = class extends Transport {
1632
1645
  );
1633
1646
  this.updateSession(backingOffSession);
1634
1647
  }
1635
- onBackoffFinished(session, connPromise) {
1648
+ onBackoffFinished(session) {
1649
+ const connPromise = tracing_default.startActiveSpan("connect", async (span) => {
1650
+ try {
1651
+ return await this.createNewOutgoingConnection(session.to);
1652
+ } catch (err) {
1653
+ const errStr = coerceErrorString(err);
1654
+ span.recordException(errStr);
1655
+ span.setStatus({ code: import_api3.SpanStatusCode.ERROR });
1656
+ throw err;
1657
+ } finally {
1658
+ span.end();
1659
+ }
1660
+ });
1636
1661
  const connectingSession = ClientSessionStateGraph.transition.BackingOffToConnecting(
1637
1662
  session,
1638
1663
  connPromise,
@@ -1640,7 +1665,10 @@ var ClientTransport = class extends Transport {
1640
1665
  onConnectionEstablished: (conn) => {
1641
1666
  this.log?.debug(
1642
1667
  `connection to ${connectingSession.to} established`,
1643
- connectingSession.loggingMetadata
1668
+ {
1669
+ ...conn.loggingMetadata,
1670
+ ...connectingSession.loggingMetadata
1671
+ }
1644
1672
  );
1645
1673
  this.onConnectionEstablished(connectingSession, conn);
1646
1674
  },
@@ -1850,9 +1878,10 @@ var WebSocketClientTransport = class extends ClientTransport {
1850
1878
  };
1851
1879
  });
1852
1880
  const conn = new WebSocketConnection(ws);
1853
- this.log?.info(`raw websocket to ${to} ok, starting handshake`, {
1881
+ this.log?.info(`raw websocket to ${to} ok`, {
1854
1882
  clientId: this.clientId,
1855
- connectedTo: to
1883
+ connectedTo: to,
1884
+ ...conn.loggingMetadata
1856
1885
  });
1857
1886
  return conn;
1858
1887
  }