@replit/river 0.17.4 → 0.18.1

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/README.md +4 -3
  2. package/dist/{chunk-F3LFO3GU.js → chunk-5YDJDYVB.js} +1 -1
  3. package/dist/{chunk-Q7OSVPZ5.js → chunk-O36533OC.js} +1 -1
  4. package/dist/{chunk-4C2OXQJB.js → chunk-QBGGJSQM.js} +62 -65
  5. package/dist/{chunk-7WY3Z5ZN.js → chunk-UNTGVPI6.js} +193 -95
  6. package/dist/chunk-XCQF55SQ.js +72 -0
  7. package/dist/{connection-c4a17403.d.ts → connection-893bd769.d.ts} +1 -1
  8. package/dist/{connection-bdbd20da.d.ts → connection-89918b74.d.ts} +1 -1
  9. package/dist/index-46ed19d8.d.ts +111 -0
  10. package/dist/{index-9e300e8a.d.ts → index-d412ca83.d.ts} +4 -86
  11. package/dist/logging/index.cjs +63 -27
  12. package/dist/logging/index.d.cts +2 -34
  13. package/dist/logging/index.d.ts +2 -34
  14. package/dist/logging/index.js +7 -7
  15. package/dist/{procedures-1c0d2eee.d.ts → procedures-85e52b9c.d.ts} +4 -3
  16. package/dist/router/index.cjs +63 -66
  17. package/dist/router/index.d.cts +43 -42
  18. package/dist/router/index.d.ts +43 -42
  19. package/dist/router/index.js +2 -2
  20. package/dist/transport/impls/uds/client.cjs +162 -84
  21. package/dist/transport/impls/uds/client.d.cts +3 -2
  22. package/dist/transport/impls/uds/client.d.ts +3 -2
  23. package/dist/transport/impls/uds/client.js +7 -4
  24. package/dist/transport/impls/uds/server.cjs +130 -65
  25. package/dist/transport/impls/uds/server.d.cts +3 -2
  26. package/dist/transport/impls/uds/server.d.ts +3 -2
  27. package/dist/transport/impls/uds/server.js +3 -3
  28. package/dist/transport/impls/ws/client.cjs +166 -87
  29. package/dist/transport/impls/ws/client.d.cts +3 -2
  30. package/dist/transport/impls/ws/client.d.ts +3 -2
  31. package/dist/transport/impls/ws/client.js +11 -7
  32. package/dist/transport/impls/ws/server.cjs +130 -65
  33. package/dist/transport/impls/ws/server.d.cts +4 -3
  34. package/dist/transport/impls/ws/server.d.ts +4 -3
  35. package/dist/transport/impls/ws/server.js +3 -3
  36. package/dist/transport/index.cjs +194 -96
  37. package/dist/transport/index.d.cts +2 -1
  38. package/dist/transport/index.d.ts +2 -1
  39. package/dist/transport/index.js +2 -2
  40. package/dist/util/testHelpers.cjs +48 -17
  41. package/dist/util/testHelpers.d.cts +4 -3
  42. package/dist/util/testHelpers.d.ts +4 -3
  43. package/dist/util/testHelpers.js +3 -3
  44. package/package.json +1 -1
  45. package/dist/chunk-H4BYJELI.js +0 -37
@@ -96,8 +96,8 @@ function isAck(controlFlag) {
96
96
  return (controlFlag & 1 /* AckBit */) === 1 /* AckBit */;
97
97
  }
98
98
 
99
- // logging/index.ts
100
- var log;
99
+ // logging/log.ts
100
+ var log = void 0;
101
101
 
102
102
  // transport/events.ts
103
103
  var ProtocolError = {
@@ -199,6 +199,14 @@ var Session = class {
199
199
  options.heartbeatIntervalMs
200
200
  );
201
201
  }
202
+ get loggingMetadata() {
203
+ return {
204
+ clientId: this.from,
205
+ connectedTo: this.to,
206
+ sessionId: this.id,
207
+ connId: this.connection?.debugId
208
+ };
209
+ }
202
210
  /**
203
211
  * Sends a message over the session's connection.
204
212
  * If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
@@ -209,26 +217,37 @@ var Session = class {
209
217
  */
210
218
  send(msg) {
211
219
  const fullMsg = this.constructMsg(msg);
212
- log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
220
+ log?.debug(`sending msg`, {
221
+ ...this.loggingMetadata,
222
+ fullTransportMessage: fullMsg
223
+ });
213
224
  if (this.connection) {
214
225
  const ok = this.connection.send(this.codec.toBuffer(fullMsg));
215
226
  if (ok)
216
227
  return fullMsg.id;
217
228
  log?.info(
218
- `${this.from} -- failed to send ${fullMsg.id} (seq: ${fullMsg.seq}) to ${fullMsg.to}, connection (id: ${this.connection.debugId}) is probably dead`
229
+ `failed to send msg to ${fullMsg.to}, connection is probably dead`,
230
+ {
231
+ ...this.loggingMetadata,
232
+ fullTransportMessage: fullMsg
233
+ }
219
234
  );
220
235
  } else {
221
236
  log?.info(
222
- `${this.from} -- failed to send ${fullMsg.id} (seq: ${fullMsg.seq}) to ${fullMsg.to}, connection not ready yet`
237
+ `failed to send msg to ${fullMsg.to}, connection not ready yet`,
238
+ { ...this.loggingMetadata, fullTransportMessage: fullMsg }
223
239
  );
224
240
  }
225
241
  return fullMsg.id;
226
242
  }
227
243
  sendHeartbeat() {
228
- if (this.heartbeatMisses >= this.options.heartbeatsUntilDead) {
244
+ const misses = this.heartbeatMisses;
245
+ const missDuration = misses * this.options.heartbeatIntervalMs;
246
+ if (misses > this.options.heartbeatsUntilDead) {
229
247
  if (this.connection) {
230
248
  log?.info(
231
- `${this.from} -- closing connection (id: ${this.connection.debugId}) to ${this.to} due to inactivity`
249
+ `closing connection to ${this.to} due to inactivity (missed ${misses} heartbeats which is ${missDuration}ms)`,
250
+ this.loggingMetadata
232
251
  );
233
252
  this.closeStaleConnection();
234
253
  }
@@ -250,26 +269,36 @@ var Session = class {
250
269
  }
251
270
  sendBufferedMessages() {
252
271
  if (!this.connection) {
253
- const msg = `${this.from} -- tried sending buffered messages without a connection (if you hit this code path something is seriously wrong)`;
254
- log?.error(msg);
272
+ const msg = `tried sending buffered messages without a connection (if you hit this code path something is seriously wrong)`;
273
+ log?.error(msg, this.loggingMetadata);
255
274
  throw new Error(msg);
256
275
  }
257
276
  log?.info(
258
- `${this.from} -- resending ${this.sendBuffer.length} buffered messages`
277
+ `resending ${this.sendBuffer.length} buffered messages`,
278
+ this.loggingMetadata
259
279
  );
260
280
  for (const msg of this.sendBuffer) {
261
- log?.debug(`${this.from} -- resending ${msg.id} (seq: ${msg.seq})`);
281
+ log?.debug(`resending msg`, {
282
+ ...this.loggingMetadata,
283
+ fullTransportMessage: msg
284
+ });
262
285
  const ok = this.connection.send(this.codec.toBuffer(msg));
263
286
  if (!ok) {
264
- const msg2 = `${this.from} -- failed to send buffered message to ${this.to} in session (id: ${this.id}) (if you hit this code path something is seriously wrong)`;
265
- log?.error(msg2);
266
- throw new Error(msg2);
287
+ const errMsg = `failed to send buffered message to ${this.to} (if you hit this code path something is seriously wrong)`;
288
+ log?.error(errMsg, {
289
+ ...this.loggingMetadata,
290
+ fullTransportMessage: msg
291
+ });
292
+ throw new Error(errMsg);
267
293
  }
268
294
  }
269
295
  }
270
296
  updateBookkeeping(ack, seq) {
271
297
  if (seq + 1 < this.ack) {
272
- log?.error(`${this.from} -- received stale seq ${seq} + 1 < ${this.ack}`);
298
+ log?.error(
299
+ `received stale seq ${seq} + 1 < ${this.ack}`,
300
+ this.loggingMetadata
301
+ );
273
302
  return;
274
303
  }
275
304
  this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
@@ -279,7 +308,8 @@ var Session = class {
279
308
  if (this.connection === void 0 || this.connection === conn)
280
309
  return;
281
310
  log?.info(
282
- `${this.from} -- closing old inner connection (id: ${this.connection.debugId}) from session (id: ${this.id}) to ${this.to}`
311
+ `closing old inner connection from session to ${this.to}`,
312
+ this.loggingMetadata
283
313
  );
284
314
  this.connection.close();
285
315
  this.connection = void 0;
@@ -291,7 +321,8 @@ var Session = class {
291
321
  }
292
322
  beginGrace(cb) {
293
323
  log?.info(
294
- `${this.from} -- starting ${this.options.sessionDisconnectGraceMs}ms grace period until session (id: ${this.id}) to ${this.to} is closed`
324
+ `starting ${this.options.sessionDisconnectGraceMs}ms grace period until session to ${this.to} is closed`,
325
+ this.loggingMetadata
295
326
  );
296
327
  this.disconnectionGrace = setTimeout(() => {
297
328
  this.close();
@@ -546,7 +577,8 @@ var Transport = class {
546
577
  let oldSession = this.sessions.get(connectedTo);
547
578
  if (oldSession?.advertisedSessionId && oldSession.advertisedSessionId !== advertisedSessionId) {
548
579
  log?.warn(
549
- `${this.clientId} -- connection from ${connectedTo} is a different session (id: ${advertisedSessionId}, last connected to: ${oldSession.advertisedSessionId}), starting a new session`
580
+ `connection from ${connectedTo} is a different session (id: ${advertisedSessionId}, last connected to: ${oldSession.advertisedSessionId}), killing old session and starting a new one`,
581
+ oldSession.loggingMetadata
550
582
  );
551
583
  this.deleteSession(oldSession);
552
584
  oldSession = void 0;
@@ -555,16 +587,18 @@ var Transport = class {
555
587
  const newSession = this.createSession(connectedTo, conn);
556
588
  newSession.advertisedSessionId = advertisedSessionId;
557
589
  log?.info(
558
- `${this.clientId} -- new connection (id: ${conn.debugId}) for new session (id: ${newSession.id}) to ${connectedTo}`
590
+ `new connection for new session to ${connectedTo}`,
591
+ newSession.loggingMetadata
559
592
  );
560
593
  return newSession;
561
594
  }
562
- log?.info(
563
- `${this.clientId} -- new connection (id: ${conn.debugId}) for existing session (id: ${oldSession.id}) to ${connectedTo}`
564
- );
565
595
  oldSession.replaceWithNewConnection(conn);
566
596
  oldSession.sendBufferedMessages();
567
597
  oldSession.advertisedSessionId = advertisedSessionId;
598
+ log?.info(
599
+ `new connection for existing session to ${connectedTo}`,
600
+ oldSession.loggingMetadata
601
+ );
568
602
  return oldSession;
569
603
  }
570
604
  createSession(to, conn) {
@@ -586,7 +620,8 @@ var Transport = class {
586
620
  if (!session) {
587
621
  session = this.createSession(to, conn);
588
622
  log?.info(
589
- `${this.clientId} -- no session for ${to}, created a new one (id: ${session.id})`
623
+ `no session for ${to}, created a new one`,
624
+ session.loggingMetadata
590
625
  );
591
626
  }
592
627
  return session;
@@ -595,7 +630,8 @@ var Transport = class {
595
630
  session.close();
596
631
  this.sessions.delete(session.to);
597
632
  log?.info(
598
- `${this.clientId} -- session ${session.id} disconnect from ${session.to}`
633
+ `session ${session.id} disconnect from ${session.to}`,
634
+ session.loggingMetadata
599
635
  );
600
636
  this.eventDispatcher.dispatchEvent("sessionStatus", {
601
637
  status: "disconnect",
@@ -624,17 +660,15 @@ var Transport = class {
624
660
  const parsedMsg = this.codec.fromBuffer(msg);
625
661
  if (parsedMsg === null) {
626
662
  const decodedBuffer = new TextDecoder().decode(Buffer.from(msg));
627
- log?.error(
628
- `${this.clientId} -- received malformed msg, killing conn: ${decodedBuffer}`
629
- );
663
+ log?.error(`received malformed msg, killing conn: ${decodedBuffer}`, {
664
+ clientId: this.clientId
665
+ });
630
666
  return null;
631
667
  }
632
668
  if (!import_value.Value.Check(OpaqueTransportMessageSchema, parsedMsg)) {
633
- log?.error(
634
- `${this.clientId} -- received invalid msg: ${JSON.stringify(
635
- parsedMsg
636
- )}`
637
- );
669
+ log?.error(`received invalid msg: ${JSON.stringify(parsedMsg)}`, {
670
+ clientId: this.clientId
671
+ });
638
672
  return null;
639
673
  }
640
674
  return parsedMsg;
@@ -649,26 +683,29 @@ var Transport = class {
649
683
  return;
650
684
  const session = this.sessions.get(msg.from);
651
685
  if (!session) {
652
- const err = `${this.clientId} -- (invariant violation) no existing session for ${msg.from}`;
653
- log?.error(err);
686
+ log?.error(`(invariant violation) no existing session for ${msg.from}`, {
687
+ clientId: this.clientId,
688
+ fullTransportMessage: msg
689
+ });
654
690
  return;
655
691
  }
656
692
  session.cancelGrace();
657
- log?.debug(`${this.clientId} -- received msg: ${JSON.stringify(msg)}`);
693
+ log?.debug(`received msg`, {
694
+ clientId: this.clientId,
695
+ fullTransportMessage: msg
696
+ });
658
697
  if (msg.seq !== session.nextExpectedSeq) {
659
698
  if (msg.seq < session.nextExpectedSeq) {
660
699
  log?.debug(
661
- `${this.clientId} -- received duplicate msg (got: ${msg.seq}, wanted: ${session.nextExpectedSeq}), discarding: ${JSON.stringify(
662
- msg
663
- )}`
700
+ `received duplicate msg (got seq: ${msg.seq}, wanted seq: ${session.nextExpectedSeq}), discarding`,
701
+ { clientId: this.clientId, fullTransportMessage: msg }
664
702
  );
665
703
  } else {
666
704
  const errMsg = `received out-of-order msg (got seq: ${msg.seq}, wanted seq: ${session.nextExpectedSeq})`;
667
- log?.error(
668
- `${this.clientId} -- fatal: ${errMsg}, marking connection as dead: ${JSON.stringify(
669
- msg
670
- )}`
671
- );
705
+ log?.error(`${errMsg}, marking connection as dead`, {
706
+ clientId: this.clientId,
707
+ fullTransportMessage: msg
708
+ });
672
709
  this.protocolError(ProtocolError.MessageOrderingViolated, errMsg);
673
710
  session.close();
674
711
  }
@@ -678,7 +715,10 @@ var Transport = class {
678
715
  if (!isAck(msg.controlFlags)) {
679
716
  this.eventDispatcher.dispatchEvent("message", msg);
680
717
  } else {
681
- log?.debug(`${this.clientId} -- discarding msg ${msg.id} (ack bit set)`);
718
+ log?.debug(`discarding msg (ack bit set)`, {
719
+ clientId: this.clientId,
720
+ fullTransportMessage: msg
721
+ });
682
722
  }
683
723
  }
684
724
  /**
@@ -706,15 +746,17 @@ var Transport = class {
706
746
  send(to, msg) {
707
747
  if (this.state === "destroyed") {
708
748
  const err = "transport is destroyed, cant send";
709
- log?.error(`${this.clientId} -- ` + err + `: ${JSON.stringify(msg)}`);
749
+ log?.error(err, {
750
+ clientId: this.clientId,
751
+ partialTransportMessage: msg
752
+ });
710
753
  this.protocolError(ProtocolError.UseAfterDestroy, err);
711
754
  return void 0;
712
755
  } else if (this.state === "closed") {
713
- log?.info(
714
- `${this.clientId} -- transport closed when sending, discarding : ${JSON.stringify(
715
- msg
716
- )}`
717
- );
756
+ log?.info(`transport closed when sending, discarding`, {
757
+ clientId: this.clientId,
758
+ partialTransportMessage: msg
759
+ });
718
760
  return void 0;
719
761
  }
720
762
  return this.getOrCreateSession(to).send(msg);
@@ -742,7 +784,7 @@ var Transport = class {
742
784
  for (const session of this.sessions.values()) {
743
785
  this.deleteSession(session);
744
786
  }
745
- log?.info(`${this.clientId} -- manually closed transport`);
787
+ log?.info(`manually closed transport`, { clientId: this.clientId });
746
788
  }
747
789
  /**
748
790
  * Default destroy implementation for transports. You should override this in the downstream
@@ -754,7 +796,7 @@ var Transport = class {
754
796
  for (const session of this.sessions.values()) {
755
797
  this.deleteSession(session);
756
798
  }
757
- log?.info(`${this.clientId} -- manually destroyed transport`);
799
+ log?.info(`manually destroyed transport`, { clientId: this.clientId });
758
800
  }
759
801
  };
760
802
  var ClientTransport = class extends Transport {
@@ -787,6 +829,15 @@ var ClientTransport = class extends Transport {
787
829
  if (this.state !== "open")
788
830
  return;
789
831
  let session = void 0;
832
+ const handshakeTimeout = setTimeout(() => {
833
+ if (!session) {
834
+ log?.warn(
835
+ `connection to ${to} timed out waiting for handshake, closing`,
836
+ { clientId: this.clientId, connectedTo: to, connId: conn.debugId }
837
+ );
838
+ conn.close();
839
+ }
840
+ }, this.options.sessionDisconnectGraceMs);
790
841
  const handshakeHandler = (data) => {
791
842
  const maybeSession = this.receiveHandshakeResponseMessage(data, conn);
792
843
  if (!maybeSession) {
@@ -794,6 +845,7 @@ var ClientTransport = class extends Transport {
794
845
  return;
795
846
  } else {
796
847
  session = maybeSession;
848
+ clearTimeout(handshakeTimeout);
797
849
  }
798
850
  conn.removeDataListener(handshakeHandler);
799
851
  conn.addDataListener((data2) => {
@@ -810,18 +862,22 @@ var ClientTransport = class extends Transport {
810
862
  if (session) {
811
863
  this.onDisconnect(conn, session);
812
864
  }
813
- log?.info(
814
- `${this.clientId} -- connection (id: ${conn.debugId}) to ${to} disconnected`
815
- );
865
+ log?.info(`connection to ${to} disconnected`, {
866
+ ...session?.loggingMetadata,
867
+ clientId: this.clientId,
868
+ connectedTo: to
869
+ });
816
870
  this.inflightConnectionPromises.delete(to);
817
871
  if (this.reconnectOnConnectionDrop) {
818
872
  void this.connect(to);
819
873
  }
820
874
  });
821
875
  conn.addErrorListener((err) => {
822
- log?.warn(
823
- `${this.clientId} -- error in connection (id: ${conn.debugId}) to ${to}: ${coerceErrorString(err)}`
824
- );
876
+ log?.warn(`error in connection to ${to}: ${coerceErrorString(err)}`, {
877
+ ...session?.loggingMetadata,
878
+ clientId: this.clientId,
879
+ connectedTo: to
880
+ });
825
881
  });
826
882
  }
827
883
  receiveHandshakeResponseMessage(data, conn) {
@@ -834,11 +890,11 @@ var ClientTransport = class extends Transport {
834
890
  return false;
835
891
  }
836
892
  if (!import_value.Value.Check(ControlMessageHandshakeResponseSchema, parsed.payload)) {
837
- log?.warn(
838
- `${this.clientId} -- received invalid handshake resp: ${JSON.stringify(
839
- parsed
840
- )}`
841
- );
893
+ log?.warn(`received invalid handshake resp`, {
894
+ clientId: this.clientId,
895
+ connectedTo: parsed.from,
896
+ fullTransportMessage: parsed
897
+ });
842
898
  this.protocolError(
843
899
  ProtocolError.HandshakeFailed,
844
900
  "invalid handshake resp"
@@ -846,18 +902,22 @@ var ClientTransport = class extends Transport {
846
902
  return false;
847
903
  }
848
904
  if (!parsed.payload.status.ok) {
849
- log?.warn(
850
- `${this.clientId} -- received failed handshake resp: ${JSON.stringify(
851
- parsed
852
- )}`
853
- );
905
+ log?.warn(`received invalid handshake resp`, {
906
+ clientId: this.clientId,
907
+ connectedTo: parsed.from,
908
+ fullTransportMessage: parsed
909
+ });
854
910
  this.protocolError(
855
911
  ProtocolError.HandshakeFailed,
856
912
  parsed.payload.status.reason
857
913
  );
858
914
  return false;
859
915
  }
860
- log?.debug(`${this.clientId} -- handshake from ${parsed.from} ok`);
916
+ log?.debug(`handshake from ${parsed.from} ok`, {
917
+ clientId: this.clientId,
918
+ connectedTo: parsed.from,
919
+ fullTransportMessage: parsed
920
+ });
861
921
  const session = this.onConnect(
862
922
  conn,
863
923
  parsed.from,
@@ -874,7 +934,8 @@ var ClientTransport = class extends Transport {
874
934
  const canProceedWithConnection = () => this.state === "open";
875
935
  if (!canProceedWithConnection()) {
876
936
  log?.info(
877
- `${this.clientId} -- transport state is no longer open, cancelling attempt to connect to ${to}`
937
+ `transport state is no longer open, cancelling attempt to connect to ${to}`,
938
+ { clientId: this.clientId, connectedTo: to }
878
939
  );
879
940
  return;
880
941
  }
@@ -883,7 +944,7 @@ var ClientTransport = class extends Transport {
883
944
  const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
884
945
  if (!this.retryBudget.hasBudget(to)) {
885
946
  const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
886
- log?.warn(`${this.clientId} -- ${errMsg}`);
947
+ log?.warn(errMsg, { clientId: this.clientId, connectedTo: to });
887
948
  this.protocolError(ProtocolError.RetriesExceeded, errMsg);
888
949
  return;
889
950
  }
@@ -892,9 +953,10 @@ var ClientTransport = class extends Transport {
892
953
  if (backoffMs > 0) {
893
954
  sleep = new Promise((resolve) => setTimeout(resolve, backoffMs));
894
955
  }
895
- log?.info(
896
- `${this.clientId} -- attempting connection to ${to} (${backoffMs}ms backoff)`
897
- );
956
+ log?.info(`attempting connection to ${to} (${backoffMs}ms backoff)`, {
957
+ clientId: this.clientId,
958
+ connectedTo: to
959
+ });
898
960
  this.retryBudget.consumeBudget(to);
899
961
  reconnectPromise = sleep.then(() => {
900
962
  if (!canProceedWithConnection()) {
@@ -903,7 +965,12 @@ var ClientTransport = class extends Transport {
903
965
  }).then(() => this.createNewOutgoingConnection(to)).then((conn) => {
904
966
  if (!canProceedWithConnection()) {
905
967
  log?.info(
906
- `${this.clientId} -- transport state is no longer open, closing pre-handshake connection (id: ${conn.debugId}) to ${to}`
968
+ `transport state is no longer open, closing pre-handshake connection to ${to}`,
969
+ {
970
+ clientId: this.clientId,
971
+ connectedTo: to,
972
+ connId: conn.debugId
973
+ }
907
974
  );
908
975
  conn.close();
909
976
  throw new Error("transport state is no longer open");
@@ -913,9 +980,10 @@ var ClientTransport = class extends Transport {
913
980
  });
914
981
  this.inflightConnectionPromises.set(to, reconnectPromise);
915
982
  } else {
916
- log?.info(
917
- `${this.clientId} -- attempting connection to ${to} (reusing previous attempt)`
918
- );
983
+ log?.info(`attempting connection to ${to} (reusing previous attempt)`, {
984
+ clientId: this.clientId,
985
+ connectedTo: to
986
+ });
919
987
  }
920
988
  try {
921
989
  await reconnectPromise;
@@ -923,11 +991,15 @@ var ClientTransport = class extends Transport {
923
991
  this.inflightConnectionPromises.delete(to);
924
992
  const errStr = coerceErrorString(error);
925
993
  if (!this.reconnectOnConnectionDrop || !canProceedWithConnection()) {
926
- log?.warn(`${this.clientId} -- connection to ${to} failed (${errStr})`);
994
+ log?.warn(`connection to ${to} failed (${errStr})`, {
995
+ clientId: this.clientId,
996
+ connectedTo: to
997
+ });
927
998
  } else {
928
- log?.warn(
929
- `${this.clientId} -- connection to ${to} failed (${errStr}), retrying`
930
- );
999
+ log?.warn(`connection to ${to} failed (${errStr}), retrying`, {
1000
+ clientId: this.clientId,
1001
+ connectedTo: to
1002
+ });
931
1003
  return this.connect(to);
932
1004
  }
933
1005
  }
@@ -939,7 +1011,10 @@ var ClientTransport = class extends Transport {
939
1011
  sendHandshake(to, conn) {
940
1012
  const session = this.getOrCreateSession(to, conn);
941
1013
  const requestMsg = handshakeRequestMessage(this.clientId, to, session.id);
942
- log?.debug(`${this.clientId} -- sending handshake request to ${to}`);
1014
+ log?.debug(`sending handshake request to ${to}`, {
1015
+ clientId: this.clientId,
1016
+ connectedTo: to
1017
+ });
943
1018
  conn.send(this.codec.toBuffer(requestMsg));
944
1019
  }
945
1020
  close() {
@@ -1000,7 +1075,10 @@ var WebSocketClientTransport = class extends ClientTransport {
1000
1075
  }
1001
1076
  async createNewOutgoingConnection(to) {
1002
1077
  const wsRes = await new Promise((resolve) => {
1003
- log?.info(`${this.clientId} -- establishing a new websocket to ${to}`);
1078
+ log?.info(`establishing a new websocket to ${to}`, {
1079
+ clientId: this.clientId,
1080
+ connectedTo: to
1081
+ });
1004
1082
  this.wsGetter(to).then((ws) => {
1005
1083
  if (ws.readyState === ws.OPEN) {
1006
1084
  resolve({ ws });
@@ -1029,9 +1107,10 @@ var WebSocketClientTransport = class extends ClientTransport {
1029
1107
  });
1030
1108
  if ("ws" in wsRes) {
1031
1109
  const conn = new WebSocketConnection(wsRes.ws);
1032
- log?.info(
1033
- `${this.clientId} -- websocket (id: ${conn.debugId}) to ${to} ok`
1034
- );
1110
+ log?.info(`raw websocket to ${to} ok, starting handshake`, {
1111
+ clientId: this.clientId,
1112
+ connectedTo: to
1113
+ });
1035
1114
  this.handleConnection(conn, to);
1036
1115
  return conn;
1037
1116
  } else {
@@ -1,6 +1,7 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { b as ClientTransport, c as TransportClientId, d as ProvidedClientTransportOptions } from '../../../index-9e300e8a.js';
3
- import { W as WebSocketConnection } from '../../../connection-c4a17403.js';
2
+ import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-d412ca83.js';
3
+ import { T as TransportClientId } from '../../../index-46ed19d8.js';
4
+ import { W as WebSocketConnection } from '../../../connection-893bd769.js';
4
5
  import '../../../types-3e5768ec.js';
5
6
  import '@sinclair/typebox';
6
7
 
@@ -1,6 +1,7 @@
1
1
  import WebSocket from 'isomorphic-ws';
2
- import { b as ClientTransport, c as TransportClientId, d as ProvidedClientTransportOptions } from '../../../index-9e300e8a.js';
3
- import { W as WebSocketConnection } from '../../../connection-c4a17403.js';
2
+ import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-d412ca83.js';
3
+ import { T as TransportClientId } from '../../../index-46ed19d8.js';
4
+ import { W as WebSocketConnection } from '../../../connection-893bd769.js';
4
5
  import '../../../types-3e5768ec.js';
5
6
  import '@sinclair/typebox';
6
7
 
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  WebSocketConnection
3
- } from "../../../chunk-F3LFO3GU.js";
3
+ } from "../../../chunk-5YDJDYVB.js";
4
4
  import {
5
5
  ClientTransport
6
- } from "../../../chunk-7WY3Z5ZN.js";
6
+ } from "../../../chunk-UNTGVPI6.js";
7
7
  import "../../../chunk-VH3NGOXQ.js";
8
8
  import {
9
9
  log
10
- } from "../../../chunk-H4BYJELI.js";
10
+ } from "../../../chunk-XCQF55SQ.js";
11
11
  import "../../../chunk-GZ7HCLLM.js";
12
12
 
13
13
  // transport/impls/ws/client.ts
@@ -29,7 +29,10 @@ var WebSocketClientTransport = class extends ClientTransport {
29
29
  }
30
30
  async createNewOutgoingConnection(to) {
31
31
  const wsRes = await new Promise((resolve) => {
32
- log?.info(`${this.clientId} -- establishing a new websocket to ${to}`);
32
+ log?.info(`establishing a new websocket to ${to}`, {
33
+ clientId: this.clientId,
34
+ connectedTo: to
35
+ });
33
36
  this.wsGetter(to).then((ws) => {
34
37
  if (ws.readyState === ws.OPEN) {
35
38
  resolve({ ws });
@@ -58,9 +61,10 @@ var WebSocketClientTransport = class extends ClientTransport {
58
61
  });
59
62
  if ("ws" in wsRes) {
60
63
  const conn = new WebSocketConnection(wsRes.ws);
61
- log?.info(
62
- `${this.clientId} -- websocket (id: ${conn.debugId}) to ${to} ok`
63
- );
64
+ log?.info(`raw websocket to ${to} ok, starting handshake`, {
65
+ clientId: this.clientId,
66
+ connectedTo: to
67
+ });
64
68
  this.handleConnection(conn, to);
65
69
  return conn;
66
70
  } else {