@replit/river 0.17.3 → 0.18.0
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.
- package/README.md +4 -3
- package/dist/{chunk-7WY3Z5ZN.js → chunk-CLY7AQ25.js} +169 -95
- package/dist/{chunk-4C2OXQJB.js → chunk-TIFNW5GQ.js} +62 -65
- package/dist/{chunk-F3LFO3GU.js → chunk-UEKU6XRG.js} +1 -1
- package/dist/chunk-YITXOAPA.js +72 -0
- package/dist/{chunk-Q7OSVPZ5.js → chunk-ZPPKYJI7.js} +1 -1
- package/dist/{connection-713c8c66.d.ts → connection-32bf6608.d.ts} +1 -1
- package/dist/{connection-b79329de.d.ts → connection-df5f32ee.d.ts} +1 -1
- package/dist/{index-80f87385.d.ts → index-314e676a.d.ts} +4 -86
- package/dist/index-6118cd48.d.ts +117 -0
- package/dist/logging/index.cjs +63 -27
- package/dist/logging/index.d.cts +2 -34
- package/dist/logging/index.d.ts +2 -34
- package/dist/logging/index.js +7 -7
- package/dist/{procedures-79a5f07e.d.ts → procedures-74a10937.d.ts} +4 -3
- package/dist/router/index.cjs +63 -66
- package/dist/router/index.d.cts +43 -42
- package/dist/router/index.d.ts +43 -42
- package/dist/router/index.js +2 -2
- package/dist/transport/impls/uds/client.cjs +152 -84
- package/dist/transport/impls/uds/client.d.cts +3 -2
- package/dist/transport/impls/uds/client.d.ts +3 -2
- package/dist/transport/impls/uds/client.js +7 -4
- package/dist/transport/impls/uds/server.cjs +116 -65
- package/dist/transport/impls/uds/server.d.cts +3 -2
- package/dist/transport/impls/uds/server.d.ts +3 -2
- package/dist/transport/impls/uds/server.js +3 -3
- package/dist/transport/impls/ws/client.cjs +156 -87
- package/dist/transport/impls/ws/client.d.cts +3 -2
- package/dist/transport/impls/ws/client.d.ts +3 -2
- package/dist/transport/impls/ws/client.js +11 -7
- package/dist/transport/impls/ws/server.cjs +116 -65
- package/dist/transport/impls/ws/server.d.cts +4 -3
- package/dist/transport/impls/ws/server.d.ts +4 -3
- package/dist/transport/impls/ws/server.js +3 -3
- package/dist/transport/index.cjs +170 -96
- package/dist/transport/index.d.cts +2 -1
- package/dist/transport/index.d.ts +2 -1
- package/dist/transport/index.js +2 -2
- package/dist/util/testHelpers.cjs +65 -32
- package/dist/util/testHelpers.d.cts +8 -7
- package/dist/util/testHelpers.d.ts +8 -7
- package/dist/util/testHelpers.js +20 -18
- package/package.json +1 -1
- 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/
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
277
|
+
`resending ${this.sendBuffer.length} buffered messages`,
|
|
278
|
+
this.loggingMetadata
|
|
259
279
|
);
|
|
260
280
|
for (const msg of this.sendBuffer) {
|
|
261
|
-
log?.debug(
|
|
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
|
|
265
|
-
log?.error(
|
|
266
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
635
|
-
|
|
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
|
-
|
|
653
|
-
|
|
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(
|
|
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
|
-
|
|
662
|
-
|
|
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
|
-
|
|
669
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
715
|
-
|
|
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(
|
|
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(
|
|
799
|
+
log?.info(`manually destroyed transport`, { clientId: this.clientId });
|
|
758
800
|
}
|
|
759
801
|
};
|
|
760
802
|
var ClientTransport = class extends Transport {
|
|
@@ -810,18 +852,22 @@ var ClientTransport = class extends Transport {
|
|
|
810
852
|
if (session) {
|
|
811
853
|
this.onDisconnect(conn, session);
|
|
812
854
|
}
|
|
813
|
-
log?.info(
|
|
814
|
-
|
|
815
|
-
|
|
855
|
+
log?.info(`connection to ${to} disconnected`, {
|
|
856
|
+
...session?.loggingMetadata,
|
|
857
|
+
clientId: this.clientId,
|
|
858
|
+
connectedTo: to
|
|
859
|
+
});
|
|
816
860
|
this.inflightConnectionPromises.delete(to);
|
|
817
861
|
if (this.reconnectOnConnectionDrop) {
|
|
818
862
|
void this.connect(to);
|
|
819
863
|
}
|
|
820
864
|
});
|
|
821
865
|
conn.addErrorListener((err) => {
|
|
822
|
-
log?.warn(
|
|
823
|
-
|
|
824
|
-
|
|
866
|
+
log?.warn(`error in connection to ${to}: ${coerceErrorString(err)}`, {
|
|
867
|
+
...session?.loggingMetadata,
|
|
868
|
+
clientId: this.clientId,
|
|
869
|
+
connectedTo: to
|
|
870
|
+
});
|
|
825
871
|
});
|
|
826
872
|
}
|
|
827
873
|
receiveHandshakeResponseMessage(data, conn) {
|
|
@@ -834,11 +880,11 @@ var ClientTransport = class extends Transport {
|
|
|
834
880
|
return false;
|
|
835
881
|
}
|
|
836
882
|
if (!import_value.Value.Check(ControlMessageHandshakeResponseSchema, parsed.payload)) {
|
|
837
|
-
log?.warn(
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
);
|
|
883
|
+
log?.warn(`received invalid handshake resp`, {
|
|
884
|
+
clientId: this.clientId,
|
|
885
|
+
connectedTo: parsed.from,
|
|
886
|
+
fullTransportMessage: parsed
|
|
887
|
+
});
|
|
842
888
|
this.protocolError(
|
|
843
889
|
ProtocolError.HandshakeFailed,
|
|
844
890
|
"invalid handshake resp"
|
|
@@ -846,18 +892,22 @@ var ClientTransport = class extends Transport {
|
|
|
846
892
|
return false;
|
|
847
893
|
}
|
|
848
894
|
if (!parsed.payload.status.ok) {
|
|
849
|
-
log?.warn(
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
);
|
|
895
|
+
log?.warn(`received invalid handshake resp`, {
|
|
896
|
+
clientId: this.clientId,
|
|
897
|
+
connectedTo: parsed.from,
|
|
898
|
+
fullTransportMessage: parsed
|
|
899
|
+
});
|
|
854
900
|
this.protocolError(
|
|
855
901
|
ProtocolError.HandshakeFailed,
|
|
856
902
|
parsed.payload.status.reason
|
|
857
903
|
);
|
|
858
904
|
return false;
|
|
859
905
|
}
|
|
860
|
-
log?.debug(
|
|
906
|
+
log?.debug(`handshake from ${parsed.from} ok`, {
|
|
907
|
+
clientId: this.clientId,
|
|
908
|
+
connectedTo: parsed.from,
|
|
909
|
+
fullTransportMessage: parsed
|
|
910
|
+
});
|
|
861
911
|
const session = this.onConnect(
|
|
862
912
|
conn,
|
|
863
913
|
parsed.from,
|
|
@@ -874,7 +924,8 @@ var ClientTransport = class extends Transport {
|
|
|
874
924
|
const canProceedWithConnection = () => this.state === "open";
|
|
875
925
|
if (!canProceedWithConnection()) {
|
|
876
926
|
log?.info(
|
|
877
|
-
|
|
927
|
+
`transport state is no longer open, cancelling attempt to connect to ${to}`,
|
|
928
|
+
{ clientId: this.clientId, connectedTo: to }
|
|
878
929
|
);
|
|
879
930
|
return;
|
|
880
931
|
}
|
|
@@ -883,7 +934,7 @@ var ClientTransport = class extends Transport {
|
|
|
883
934
|
const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
|
|
884
935
|
if (!this.retryBudget.hasBudget(to)) {
|
|
885
936
|
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(
|
|
937
|
+
log?.warn(errMsg, { clientId: this.clientId, connectedTo: to });
|
|
887
938
|
this.protocolError(ProtocolError.RetriesExceeded, errMsg);
|
|
888
939
|
return;
|
|
889
940
|
}
|
|
@@ -892,9 +943,10 @@ var ClientTransport = class extends Transport {
|
|
|
892
943
|
if (backoffMs > 0) {
|
|
893
944
|
sleep = new Promise((resolve) => setTimeout(resolve, backoffMs));
|
|
894
945
|
}
|
|
895
|
-
log?.info(
|
|
896
|
-
|
|
897
|
-
|
|
946
|
+
log?.info(`attempting connection to ${to} (${backoffMs}ms backoff)`, {
|
|
947
|
+
clientId: this.clientId,
|
|
948
|
+
connectedTo: to
|
|
949
|
+
});
|
|
898
950
|
this.retryBudget.consumeBudget(to);
|
|
899
951
|
reconnectPromise = sleep.then(() => {
|
|
900
952
|
if (!canProceedWithConnection()) {
|
|
@@ -903,7 +955,12 @@ var ClientTransport = class extends Transport {
|
|
|
903
955
|
}).then(() => this.createNewOutgoingConnection(to)).then((conn) => {
|
|
904
956
|
if (!canProceedWithConnection()) {
|
|
905
957
|
log?.info(
|
|
906
|
-
|
|
958
|
+
`transport state is no longer open, closing pre-handshake connection to ${to}`,
|
|
959
|
+
{
|
|
960
|
+
clientId: this.clientId,
|
|
961
|
+
connectedTo: to,
|
|
962
|
+
connId: conn.debugId
|
|
963
|
+
}
|
|
907
964
|
);
|
|
908
965
|
conn.close();
|
|
909
966
|
throw new Error("transport state is no longer open");
|
|
@@ -913,9 +970,10 @@ var ClientTransport = class extends Transport {
|
|
|
913
970
|
});
|
|
914
971
|
this.inflightConnectionPromises.set(to, reconnectPromise);
|
|
915
972
|
} else {
|
|
916
|
-
log?.info(
|
|
917
|
-
|
|
918
|
-
|
|
973
|
+
log?.info(`attempting connection to ${to} (reusing previous attempt)`, {
|
|
974
|
+
clientId: this.clientId,
|
|
975
|
+
connectedTo: to
|
|
976
|
+
});
|
|
919
977
|
}
|
|
920
978
|
try {
|
|
921
979
|
await reconnectPromise;
|
|
@@ -923,11 +981,15 @@ var ClientTransport = class extends Transport {
|
|
|
923
981
|
this.inflightConnectionPromises.delete(to);
|
|
924
982
|
const errStr = coerceErrorString(error);
|
|
925
983
|
if (!this.reconnectOnConnectionDrop || !canProceedWithConnection()) {
|
|
926
|
-
log?.warn(
|
|
984
|
+
log?.warn(`connection to ${to} failed (${errStr})`, {
|
|
985
|
+
clientId: this.clientId,
|
|
986
|
+
connectedTo: to
|
|
987
|
+
});
|
|
927
988
|
} else {
|
|
928
|
-
log?.warn(
|
|
929
|
-
|
|
930
|
-
|
|
989
|
+
log?.warn(`connection to ${to} failed (${errStr}), retrying`, {
|
|
990
|
+
clientId: this.clientId,
|
|
991
|
+
connectedTo: to
|
|
992
|
+
});
|
|
931
993
|
return this.connect(to);
|
|
932
994
|
}
|
|
933
995
|
}
|
|
@@ -939,7 +1001,10 @@ var ClientTransport = class extends Transport {
|
|
|
939
1001
|
sendHandshake(to, conn) {
|
|
940
1002
|
const session = this.getOrCreateSession(to, conn);
|
|
941
1003
|
const requestMsg = handshakeRequestMessage(this.clientId, to, session.id);
|
|
942
|
-
log?.debug(
|
|
1004
|
+
log?.debug(`sending handshake request to ${to}`, {
|
|
1005
|
+
clientId: this.clientId,
|
|
1006
|
+
connectedTo: to
|
|
1007
|
+
});
|
|
943
1008
|
conn.send(this.codec.toBuffer(requestMsg));
|
|
944
1009
|
}
|
|
945
1010
|
close() {
|
|
@@ -1000,7 +1065,10 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
1000
1065
|
}
|
|
1001
1066
|
async createNewOutgoingConnection(to) {
|
|
1002
1067
|
const wsRes = await new Promise((resolve) => {
|
|
1003
|
-
log?.info(
|
|
1068
|
+
log?.info(`establishing a new websocket to ${to}`, {
|
|
1069
|
+
clientId: this.clientId,
|
|
1070
|
+
connectedTo: to
|
|
1071
|
+
});
|
|
1004
1072
|
this.wsGetter(to).then((ws) => {
|
|
1005
1073
|
if (ws.readyState === ws.OPEN) {
|
|
1006
1074
|
resolve({ ws });
|
|
@@ -1029,9 +1097,10 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
1029
1097
|
});
|
|
1030
1098
|
if ("ws" in wsRes) {
|
|
1031
1099
|
const conn = new WebSocketConnection(wsRes.ws);
|
|
1032
|
-
log?.info(
|
|
1033
|
-
|
|
1034
|
-
|
|
1100
|
+
log?.info(`raw websocket to ${to} ok, starting handshake`, {
|
|
1101
|
+
clientId: this.clientId,
|
|
1102
|
+
connectedTo: to
|
|
1103
|
+
});
|
|
1035
1104
|
this.handleConnection(conn, to);
|
|
1036
1105
|
return conn;
|
|
1037
1106
|
} else {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-314e676a.js';
|
|
3
|
+
import { T as TransportClientId } from '../../../index-6118cd48.js';
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-df5f32ee.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 {
|
|
3
|
-
import {
|
|
2
|
+
import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-314e676a.js';
|
|
3
|
+
import { T as TransportClientId } from '../../../index-6118cd48.js';
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-df5f32ee.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-
|
|
3
|
+
} from "../../../chunk-UEKU6XRG.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-CLY7AQ25.js";
|
|
7
7
|
import "../../../chunk-VH3NGOXQ.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
10
|
-
} from "../../../chunk-
|
|
10
|
+
} from "../../../chunk-YITXOAPA.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(
|
|
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
|
-
|
|
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 {
|