@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.
- package/README.md +4 -3
- package/dist/{chunk-F3LFO3GU.js → chunk-5YDJDYVB.js} +1 -1
- package/dist/{chunk-Q7OSVPZ5.js → chunk-O36533OC.js} +1 -1
- package/dist/{chunk-4C2OXQJB.js → chunk-QBGGJSQM.js} +62 -65
- package/dist/{chunk-7WY3Z5ZN.js → chunk-UNTGVPI6.js} +193 -95
- package/dist/chunk-XCQF55SQ.js +72 -0
- package/dist/{connection-c4a17403.d.ts → connection-893bd769.d.ts} +1 -1
- package/dist/{connection-bdbd20da.d.ts → connection-89918b74.d.ts} +1 -1
- package/dist/index-46ed19d8.d.ts +111 -0
- package/dist/{index-9e300e8a.d.ts → index-d412ca83.d.ts} +4 -86
- 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-1c0d2eee.d.ts → procedures-85e52b9c.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 +162 -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 +130 -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 +166 -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 +130 -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 +194 -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 +48 -17
- package/dist/util/testHelpers.d.cts +4 -3
- package/dist/util/testHelpers.d.ts +4 -3
- package/dist/util/testHelpers.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-H4BYJELI.js +0 -37
|
@@ -25,8 +25,8 @@ __export(client_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(client_exports);
|
|
26
26
|
var import_node_net = require("net");
|
|
27
27
|
|
|
28
|
-
// logging/
|
|
29
|
-
var log;
|
|
28
|
+
// logging/log.ts
|
|
29
|
+
var log = void 0;
|
|
30
30
|
|
|
31
31
|
// transport/session.ts
|
|
32
32
|
var import_nanoid2 = require("nanoid");
|
|
@@ -165,6 +165,14 @@ var Session = class {
|
|
|
165
165
|
options.heartbeatIntervalMs
|
|
166
166
|
);
|
|
167
167
|
}
|
|
168
|
+
get loggingMetadata() {
|
|
169
|
+
return {
|
|
170
|
+
clientId: this.from,
|
|
171
|
+
connectedTo: this.to,
|
|
172
|
+
sessionId: this.id,
|
|
173
|
+
connId: this.connection?.debugId
|
|
174
|
+
};
|
|
175
|
+
}
|
|
168
176
|
/**
|
|
169
177
|
* Sends a message over the session's connection.
|
|
170
178
|
* If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
|
|
@@ -175,26 +183,37 @@ var Session = class {
|
|
|
175
183
|
*/
|
|
176
184
|
send(msg) {
|
|
177
185
|
const fullMsg = this.constructMsg(msg);
|
|
178
|
-
log?.debug(
|
|
186
|
+
log?.debug(`sending msg`, {
|
|
187
|
+
...this.loggingMetadata,
|
|
188
|
+
fullTransportMessage: fullMsg
|
|
189
|
+
});
|
|
179
190
|
if (this.connection) {
|
|
180
191
|
const ok = this.connection.send(this.codec.toBuffer(fullMsg));
|
|
181
192
|
if (ok)
|
|
182
193
|
return fullMsg.id;
|
|
183
194
|
log?.info(
|
|
184
|
-
|
|
195
|
+
`failed to send msg to ${fullMsg.to}, connection is probably dead`,
|
|
196
|
+
{
|
|
197
|
+
...this.loggingMetadata,
|
|
198
|
+
fullTransportMessage: fullMsg
|
|
199
|
+
}
|
|
185
200
|
);
|
|
186
201
|
} else {
|
|
187
202
|
log?.info(
|
|
188
|
-
|
|
203
|
+
`failed to send msg to ${fullMsg.to}, connection not ready yet`,
|
|
204
|
+
{ ...this.loggingMetadata, fullTransportMessage: fullMsg }
|
|
189
205
|
);
|
|
190
206
|
}
|
|
191
207
|
return fullMsg.id;
|
|
192
208
|
}
|
|
193
209
|
sendHeartbeat() {
|
|
194
|
-
|
|
210
|
+
const misses = this.heartbeatMisses;
|
|
211
|
+
const missDuration = misses * this.options.heartbeatIntervalMs;
|
|
212
|
+
if (misses > this.options.heartbeatsUntilDead) {
|
|
195
213
|
if (this.connection) {
|
|
196
214
|
log?.info(
|
|
197
|
-
|
|
215
|
+
`closing connection to ${this.to} due to inactivity (missed ${misses} heartbeats which is ${missDuration}ms)`,
|
|
216
|
+
this.loggingMetadata
|
|
198
217
|
);
|
|
199
218
|
this.closeStaleConnection();
|
|
200
219
|
}
|
|
@@ -216,26 +235,36 @@ var Session = class {
|
|
|
216
235
|
}
|
|
217
236
|
sendBufferedMessages() {
|
|
218
237
|
if (!this.connection) {
|
|
219
|
-
const msg =
|
|
220
|
-
log?.error(msg);
|
|
238
|
+
const msg = `tried sending buffered messages without a connection (if you hit this code path something is seriously wrong)`;
|
|
239
|
+
log?.error(msg, this.loggingMetadata);
|
|
221
240
|
throw new Error(msg);
|
|
222
241
|
}
|
|
223
242
|
log?.info(
|
|
224
|
-
|
|
243
|
+
`resending ${this.sendBuffer.length} buffered messages`,
|
|
244
|
+
this.loggingMetadata
|
|
225
245
|
);
|
|
226
246
|
for (const msg of this.sendBuffer) {
|
|
227
|
-
log?.debug(
|
|
247
|
+
log?.debug(`resending msg`, {
|
|
248
|
+
...this.loggingMetadata,
|
|
249
|
+
fullTransportMessage: msg
|
|
250
|
+
});
|
|
228
251
|
const ok = this.connection.send(this.codec.toBuffer(msg));
|
|
229
252
|
if (!ok) {
|
|
230
|
-
const
|
|
231
|
-
log?.error(
|
|
232
|
-
|
|
253
|
+
const errMsg = `failed to send buffered message to ${this.to} (if you hit this code path something is seriously wrong)`;
|
|
254
|
+
log?.error(errMsg, {
|
|
255
|
+
...this.loggingMetadata,
|
|
256
|
+
fullTransportMessage: msg
|
|
257
|
+
});
|
|
258
|
+
throw new Error(errMsg);
|
|
233
259
|
}
|
|
234
260
|
}
|
|
235
261
|
}
|
|
236
262
|
updateBookkeeping(ack, seq) {
|
|
237
263
|
if (seq + 1 < this.ack) {
|
|
238
|
-
log?.error(
|
|
264
|
+
log?.error(
|
|
265
|
+
`received stale seq ${seq} + 1 < ${this.ack}`,
|
|
266
|
+
this.loggingMetadata
|
|
267
|
+
);
|
|
239
268
|
return;
|
|
240
269
|
}
|
|
241
270
|
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq >= ack);
|
|
@@ -245,7 +274,8 @@ var Session = class {
|
|
|
245
274
|
if (this.connection === void 0 || this.connection === conn)
|
|
246
275
|
return;
|
|
247
276
|
log?.info(
|
|
248
|
-
|
|
277
|
+
`closing old inner connection from session to ${this.to}`,
|
|
278
|
+
this.loggingMetadata
|
|
249
279
|
);
|
|
250
280
|
this.connection.close();
|
|
251
281
|
this.connection = void 0;
|
|
@@ -257,7 +287,8 @@ var Session = class {
|
|
|
257
287
|
}
|
|
258
288
|
beginGrace(cb) {
|
|
259
289
|
log?.info(
|
|
260
|
-
|
|
290
|
+
`starting ${this.options.sessionDisconnectGraceMs}ms grace period until session to ${this.to} is closed`,
|
|
291
|
+
this.loggingMetadata
|
|
261
292
|
);
|
|
262
293
|
this.disconnectionGrace = setTimeout(() => {
|
|
263
294
|
this.close();
|
|
@@ -642,7 +673,8 @@ var Transport = class {
|
|
|
642
673
|
let oldSession = this.sessions.get(connectedTo);
|
|
643
674
|
if (oldSession?.advertisedSessionId && oldSession.advertisedSessionId !== advertisedSessionId) {
|
|
644
675
|
log?.warn(
|
|
645
|
-
|
|
676
|
+
`connection from ${connectedTo} is a different session (id: ${advertisedSessionId}, last connected to: ${oldSession.advertisedSessionId}), killing old session and starting a new one`,
|
|
677
|
+
oldSession.loggingMetadata
|
|
646
678
|
);
|
|
647
679
|
this.deleteSession(oldSession);
|
|
648
680
|
oldSession = void 0;
|
|
@@ -651,16 +683,18 @@ var Transport = class {
|
|
|
651
683
|
const newSession = this.createSession(connectedTo, conn);
|
|
652
684
|
newSession.advertisedSessionId = advertisedSessionId;
|
|
653
685
|
log?.info(
|
|
654
|
-
|
|
686
|
+
`new connection for new session to ${connectedTo}`,
|
|
687
|
+
newSession.loggingMetadata
|
|
655
688
|
);
|
|
656
689
|
return newSession;
|
|
657
690
|
}
|
|
658
|
-
log?.info(
|
|
659
|
-
`${this.clientId} -- new connection (id: ${conn.debugId}) for existing session (id: ${oldSession.id}) to ${connectedTo}`
|
|
660
|
-
);
|
|
661
691
|
oldSession.replaceWithNewConnection(conn);
|
|
662
692
|
oldSession.sendBufferedMessages();
|
|
663
693
|
oldSession.advertisedSessionId = advertisedSessionId;
|
|
694
|
+
log?.info(
|
|
695
|
+
`new connection for existing session to ${connectedTo}`,
|
|
696
|
+
oldSession.loggingMetadata
|
|
697
|
+
);
|
|
664
698
|
return oldSession;
|
|
665
699
|
}
|
|
666
700
|
createSession(to, conn) {
|
|
@@ -682,7 +716,8 @@ var Transport = class {
|
|
|
682
716
|
if (!session) {
|
|
683
717
|
session = this.createSession(to, conn);
|
|
684
718
|
log?.info(
|
|
685
|
-
|
|
719
|
+
`no session for ${to}, created a new one`,
|
|
720
|
+
session.loggingMetadata
|
|
686
721
|
);
|
|
687
722
|
}
|
|
688
723
|
return session;
|
|
@@ -691,7 +726,8 @@ var Transport = class {
|
|
|
691
726
|
session.close();
|
|
692
727
|
this.sessions.delete(session.to);
|
|
693
728
|
log?.info(
|
|
694
|
-
|
|
729
|
+
`session ${session.id} disconnect from ${session.to}`,
|
|
730
|
+
session.loggingMetadata
|
|
695
731
|
);
|
|
696
732
|
this.eventDispatcher.dispatchEvent("sessionStatus", {
|
|
697
733
|
status: "disconnect",
|
|
@@ -720,17 +756,15 @@ var Transport = class {
|
|
|
720
756
|
const parsedMsg = this.codec.fromBuffer(msg);
|
|
721
757
|
if (parsedMsg === null) {
|
|
722
758
|
const decodedBuffer = new TextDecoder().decode(Buffer.from(msg));
|
|
723
|
-
log?.error(
|
|
724
|
-
|
|
725
|
-
);
|
|
759
|
+
log?.error(`received malformed msg, killing conn: ${decodedBuffer}`, {
|
|
760
|
+
clientId: this.clientId
|
|
761
|
+
});
|
|
726
762
|
return null;
|
|
727
763
|
}
|
|
728
764
|
if (!import_value.Value.Check(OpaqueTransportMessageSchema, parsedMsg)) {
|
|
729
|
-
log?.error(
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
)}`
|
|
733
|
-
);
|
|
765
|
+
log?.error(`received invalid msg: ${JSON.stringify(parsedMsg)}`, {
|
|
766
|
+
clientId: this.clientId
|
|
767
|
+
});
|
|
734
768
|
return null;
|
|
735
769
|
}
|
|
736
770
|
return parsedMsg;
|
|
@@ -745,26 +779,29 @@ var Transport = class {
|
|
|
745
779
|
return;
|
|
746
780
|
const session = this.sessions.get(msg.from);
|
|
747
781
|
if (!session) {
|
|
748
|
-
|
|
749
|
-
|
|
782
|
+
log?.error(`(invariant violation) no existing session for ${msg.from}`, {
|
|
783
|
+
clientId: this.clientId,
|
|
784
|
+
fullTransportMessage: msg
|
|
785
|
+
});
|
|
750
786
|
return;
|
|
751
787
|
}
|
|
752
788
|
session.cancelGrace();
|
|
753
|
-
log?.debug(
|
|
789
|
+
log?.debug(`received msg`, {
|
|
790
|
+
clientId: this.clientId,
|
|
791
|
+
fullTransportMessage: msg
|
|
792
|
+
});
|
|
754
793
|
if (msg.seq !== session.nextExpectedSeq) {
|
|
755
794
|
if (msg.seq < session.nextExpectedSeq) {
|
|
756
795
|
log?.debug(
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
)}`
|
|
796
|
+
`received duplicate msg (got seq: ${msg.seq}, wanted seq: ${session.nextExpectedSeq}), discarding`,
|
|
797
|
+
{ clientId: this.clientId, fullTransportMessage: msg }
|
|
760
798
|
);
|
|
761
799
|
} else {
|
|
762
800
|
const errMsg = `received out-of-order msg (got seq: ${msg.seq}, wanted seq: ${session.nextExpectedSeq})`;
|
|
763
|
-
log?.error(
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
);
|
|
801
|
+
log?.error(`${errMsg}, marking connection as dead`, {
|
|
802
|
+
clientId: this.clientId,
|
|
803
|
+
fullTransportMessage: msg
|
|
804
|
+
});
|
|
768
805
|
this.protocolError(ProtocolError.MessageOrderingViolated, errMsg);
|
|
769
806
|
session.close();
|
|
770
807
|
}
|
|
@@ -774,7 +811,10 @@ var Transport = class {
|
|
|
774
811
|
if (!isAck(msg.controlFlags)) {
|
|
775
812
|
this.eventDispatcher.dispatchEvent("message", msg);
|
|
776
813
|
} else {
|
|
777
|
-
log?.debug(
|
|
814
|
+
log?.debug(`discarding msg (ack bit set)`, {
|
|
815
|
+
clientId: this.clientId,
|
|
816
|
+
fullTransportMessage: msg
|
|
817
|
+
});
|
|
778
818
|
}
|
|
779
819
|
}
|
|
780
820
|
/**
|
|
@@ -802,15 +842,17 @@ var Transport = class {
|
|
|
802
842
|
send(to, msg) {
|
|
803
843
|
if (this.state === "destroyed") {
|
|
804
844
|
const err = "transport is destroyed, cant send";
|
|
805
|
-
log?.error(
|
|
845
|
+
log?.error(err, {
|
|
846
|
+
clientId: this.clientId,
|
|
847
|
+
partialTransportMessage: msg
|
|
848
|
+
});
|
|
806
849
|
this.protocolError(ProtocolError.UseAfterDestroy, err);
|
|
807
850
|
return void 0;
|
|
808
851
|
} else if (this.state === "closed") {
|
|
809
|
-
log?.info(
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
);
|
|
852
|
+
log?.info(`transport closed when sending, discarding`, {
|
|
853
|
+
clientId: this.clientId,
|
|
854
|
+
partialTransportMessage: msg
|
|
855
|
+
});
|
|
814
856
|
return void 0;
|
|
815
857
|
}
|
|
816
858
|
return this.getOrCreateSession(to).send(msg);
|
|
@@ -838,7 +880,7 @@ var Transport = class {
|
|
|
838
880
|
for (const session of this.sessions.values()) {
|
|
839
881
|
this.deleteSession(session);
|
|
840
882
|
}
|
|
841
|
-
log?.info(
|
|
883
|
+
log?.info(`manually closed transport`, { clientId: this.clientId });
|
|
842
884
|
}
|
|
843
885
|
/**
|
|
844
886
|
* Default destroy implementation for transports. You should override this in the downstream
|
|
@@ -850,7 +892,7 @@ var Transport = class {
|
|
|
850
892
|
for (const session of this.sessions.values()) {
|
|
851
893
|
this.deleteSession(session);
|
|
852
894
|
}
|
|
853
|
-
log?.info(
|
|
895
|
+
log?.info(`manually destroyed transport`, { clientId: this.clientId });
|
|
854
896
|
}
|
|
855
897
|
};
|
|
856
898
|
var ClientTransport = class extends Transport {
|
|
@@ -883,6 +925,15 @@ var ClientTransport = class extends Transport {
|
|
|
883
925
|
if (this.state !== "open")
|
|
884
926
|
return;
|
|
885
927
|
let session = void 0;
|
|
928
|
+
const handshakeTimeout = setTimeout(() => {
|
|
929
|
+
if (!session) {
|
|
930
|
+
log?.warn(
|
|
931
|
+
`connection to ${to} timed out waiting for handshake, closing`,
|
|
932
|
+
{ clientId: this.clientId, connectedTo: to, connId: conn.debugId }
|
|
933
|
+
);
|
|
934
|
+
conn.close();
|
|
935
|
+
}
|
|
936
|
+
}, this.options.sessionDisconnectGraceMs);
|
|
886
937
|
const handshakeHandler = (data) => {
|
|
887
938
|
const maybeSession = this.receiveHandshakeResponseMessage(data, conn);
|
|
888
939
|
if (!maybeSession) {
|
|
@@ -890,6 +941,7 @@ var ClientTransport = class extends Transport {
|
|
|
890
941
|
return;
|
|
891
942
|
} else {
|
|
892
943
|
session = maybeSession;
|
|
944
|
+
clearTimeout(handshakeTimeout);
|
|
893
945
|
}
|
|
894
946
|
conn.removeDataListener(handshakeHandler);
|
|
895
947
|
conn.addDataListener((data2) => {
|
|
@@ -906,18 +958,22 @@ var ClientTransport = class extends Transport {
|
|
|
906
958
|
if (session) {
|
|
907
959
|
this.onDisconnect(conn, session);
|
|
908
960
|
}
|
|
909
|
-
log?.info(
|
|
910
|
-
|
|
911
|
-
|
|
961
|
+
log?.info(`connection to ${to} disconnected`, {
|
|
962
|
+
...session?.loggingMetadata,
|
|
963
|
+
clientId: this.clientId,
|
|
964
|
+
connectedTo: to
|
|
965
|
+
});
|
|
912
966
|
this.inflightConnectionPromises.delete(to);
|
|
913
967
|
if (this.reconnectOnConnectionDrop) {
|
|
914
968
|
void this.connect(to);
|
|
915
969
|
}
|
|
916
970
|
});
|
|
917
971
|
conn.addErrorListener((err) => {
|
|
918
|
-
log?.warn(
|
|
919
|
-
|
|
920
|
-
|
|
972
|
+
log?.warn(`error in connection to ${to}: ${coerceErrorString(err)}`, {
|
|
973
|
+
...session?.loggingMetadata,
|
|
974
|
+
clientId: this.clientId,
|
|
975
|
+
connectedTo: to
|
|
976
|
+
});
|
|
921
977
|
});
|
|
922
978
|
}
|
|
923
979
|
receiveHandshakeResponseMessage(data, conn) {
|
|
@@ -930,11 +986,11 @@ var ClientTransport = class extends Transport {
|
|
|
930
986
|
return false;
|
|
931
987
|
}
|
|
932
988
|
if (!import_value.Value.Check(ControlMessageHandshakeResponseSchema, parsed.payload)) {
|
|
933
|
-
log?.warn(
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
);
|
|
989
|
+
log?.warn(`received invalid handshake resp`, {
|
|
990
|
+
clientId: this.clientId,
|
|
991
|
+
connectedTo: parsed.from,
|
|
992
|
+
fullTransportMessage: parsed
|
|
993
|
+
});
|
|
938
994
|
this.protocolError(
|
|
939
995
|
ProtocolError.HandshakeFailed,
|
|
940
996
|
"invalid handshake resp"
|
|
@@ -942,18 +998,22 @@ var ClientTransport = class extends Transport {
|
|
|
942
998
|
return false;
|
|
943
999
|
}
|
|
944
1000
|
if (!parsed.payload.status.ok) {
|
|
945
|
-
log?.warn(
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
);
|
|
1001
|
+
log?.warn(`received invalid handshake resp`, {
|
|
1002
|
+
clientId: this.clientId,
|
|
1003
|
+
connectedTo: parsed.from,
|
|
1004
|
+
fullTransportMessage: parsed
|
|
1005
|
+
});
|
|
950
1006
|
this.protocolError(
|
|
951
1007
|
ProtocolError.HandshakeFailed,
|
|
952
1008
|
parsed.payload.status.reason
|
|
953
1009
|
);
|
|
954
1010
|
return false;
|
|
955
1011
|
}
|
|
956
|
-
log?.debug(
|
|
1012
|
+
log?.debug(`handshake from ${parsed.from} ok`, {
|
|
1013
|
+
clientId: this.clientId,
|
|
1014
|
+
connectedTo: parsed.from,
|
|
1015
|
+
fullTransportMessage: parsed
|
|
1016
|
+
});
|
|
957
1017
|
const session = this.onConnect(
|
|
958
1018
|
conn,
|
|
959
1019
|
parsed.from,
|
|
@@ -970,7 +1030,8 @@ var ClientTransport = class extends Transport {
|
|
|
970
1030
|
const canProceedWithConnection = () => this.state === "open";
|
|
971
1031
|
if (!canProceedWithConnection()) {
|
|
972
1032
|
log?.info(
|
|
973
|
-
|
|
1033
|
+
`transport state is no longer open, cancelling attempt to connect to ${to}`,
|
|
1034
|
+
{ clientId: this.clientId, connectedTo: to }
|
|
974
1035
|
);
|
|
975
1036
|
return;
|
|
976
1037
|
}
|
|
@@ -979,7 +1040,7 @@ var ClientTransport = class extends Transport {
|
|
|
979
1040
|
const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
|
|
980
1041
|
if (!this.retryBudget.hasBudget(to)) {
|
|
981
1042
|
const errMsg = `tried to connect to ${to} but retry budget exceeded (more than ${budgetConsumed} attempts in the last ${this.retryBudget.totalBudgetRestoreTime}ms)`;
|
|
982
|
-
log?.warn(
|
|
1043
|
+
log?.warn(errMsg, { clientId: this.clientId, connectedTo: to });
|
|
983
1044
|
this.protocolError(ProtocolError.RetriesExceeded, errMsg);
|
|
984
1045
|
return;
|
|
985
1046
|
}
|
|
@@ -988,9 +1049,10 @@ var ClientTransport = class extends Transport {
|
|
|
988
1049
|
if (backoffMs > 0) {
|
|
989
1050
|
sleep = new Promise((resolve) => setTimeout(resolve, backoffMs));
|
|
990
1051
|
}
|
|
991
|
-
log?.info(
|
|
992
|
-
|
|
993
|
-
|
|
1052
|
+
log?.info(`attempting connection to ${to} (${backoffMs}ms backoff)`, {
|
|
1053
|
+
clientId: this.clientId,
|
|
1054
|
+
connectedTo: to
|
|
1055
|
+
});
|
|
994
1056
|
this.retryBudget.consumeBudget(to);
|
|
995
1057
|
reconnectPromise = sleep.then(() => {
|
|
996
1058
|
if (!canProceedWithConnection()) {
|
|
@@ -999,7 +1061,12 @@ var ClientTransport = class extends Transport {
|
|
|
999
1061
|
}).then(() => this.createNewOutgoingConnection(to)).then((conn) => {
|
|
1000
1062
|
if (!canProceedWithConnection()) {
|
|
1001
1063
|
log?.info(
|
|
1002
|
-
|
|
1064
|
+
`transport state is no longer open, closing pre-handshake connection to ${to}`,
|
|
1065
|
+
{
|
|
1066
|
+
clientId: this.clientId,
|
|
1067
|
+
connectedTo: to,
|
|
1068
|
+
connId: conn.debugId
|
|
1069
|
+
}
|
|
1003
1070
|
);
|
|
1004
1071
|
conn.close();
|
|
1005
1072
|
throw new Error("transport state is no longer open");
|
|
@@ -1009,9 +1076,10 @@ var ClientTransport = class extends Transport {
|
|
|
1009
1076
|
});
|
|
1010
1077
|
this.inflightConnectionPromises.set(to, reconnectPromise);
|
|
1011
1078
|
} else {
|
|
1012
|
-
log?.info(
|
|
1013
|
-
|
|
1014
|
-
|
|
1079
|
+
log?.info(`attempting connection to ${to} (reusing previous attempt)`, {
|
|
1080
|
+
clientId: this.clientId,
|
|
1081
|
+
connectedTo: to
|
|
1082
|
+
});
|
|
1015
1083
|
}
|
|
1016
1084
|
try {
|
|
1017
1085
|
await reconnectPromise;
|
|
@@ -1019,11 +1087,15 @@ var ClientTransport = class extends Transport {
|
|
|
1019
1087
|
this.inflightConnectionPromises.delete(to);
|
|
1020
1088
|
const errStr = coerceErrorString(error);
|
|
1021
1089
|
if (!this.reconnectOnConnectionDrop || !canProceedWithConnection()) {
|
|
1022
|
-
log?.warn(
|
|
1090
|
+
log?.warn(`connection to ${to} failed (${errStr})`, {
|
|
1091
|
+
clientId: this.clientId,
|
|
1092
|
+
connectedTo: to
|
|
1093
|
+
});
|
|
1023
1094
|
} else {
|
|
1024
|
-
log?.warn(
|
|
1025
|
-
|
|
1026
|
-
|
|
1095
|
+
log?.warn(`connection to ${to} failed (${errStr}), retrying`, {
|
|
1096
|
+
clientId: this.clientId,
|
|
1097
|
+
connectedTo: to
|
|
1098
|
+
});
|
|
1027
1099
|
return this.connect(to);
|
|
1028
1100
|
}
|
|
1029
1101
|
}
|
|
@@ -1035,7 +1107,10 @@ var ClientTransport = class extends Transport {
|
|
|
1035
1107
|
sendHandshake(to, conn) {
|
|
1036
1108
|
const session = this.getOrCreateSession(to, conn);
|
|
1037
1109
|
const requestMsg = handshakeRequestMessage(this.clientId, to, session.id);
|
|
1038
|
-
log?.debug(
|
|
1110
|
+
log?.debug(`sending handshake request to ${to}`, {
|
|
1111
|
+
clientId: this.clientId,
|
|
1112
|
+
connectedTo: to
|
|
1113
|
+
});
|
|
1039
1114
|
conn.send(this.codec.toBuffer(requestMsg));
|
|
1040
1115
|
}
|
|
1041
1116
|
close() {
|
|
@@ -1056,7 +1131,10 @@ var UnixDomainSocketClientTransport = class extends ClientTransport {
|
|
|
1056
1131
|
if (oldConnection) {
|
|
1057
1132
|
oldConnection.close();
|
|
1058
1133
|
}
|
|
1059
|
-
log?.info(
|
|
1134
|
+
log?.info(`establishing a new uds to ${to}`, {
|
|
1135
|
+
clientId: this.clientId,
|
|
1136
|
+
connectedTo: to
|
|
1137
|
+
});
|
|
1060
1138
|
const sock = await new Promise((resolve, reject) => {
|
|
1061
1139
|
const sock2 = new import_node_net.Socket();
|
|
1062
1140
|
sock2.on("connect", () => resolve(sock2));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { b as ClientTransport,
|
|
2
|
-
import {
|
|
1
|
+
import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-d412ca83.js';
|
|
2
|
+
import { T as TransportClientId } from '../../../index-46ed19d8.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-89918b74.js';
|
|
3
4
|
import '../../../types-3e5768ec.js';
|
|
4
5
|
import '@sinclair/typebox';
|
|
5
6
|
import 'node:net';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { b as ClientTransport,
|
|
2
|
-
import {
|
|
1
|
+
import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-d412ca83.js';
|
|
2
|
+
import { T as TransportClientId } from '../../../index-46ed19d8.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-89918b74.js';
|
|
3
4
|
import '../../../types-3e5768ec.js';
|
|
4
5
|
import '@sinclair/typebox';
|
|
5
6
|
import 'node:net';
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-O36533OC.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-UNTGVPI6.js";
|
|
7
7
|
import "../../../chunk-VH3NGOXQ.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
10
|
-
} from "../../../chunk-
|
|
10
|
+
} from "../../../chunk-XCQF55SQ.js";
|
|
11
11
|
import "../../../chunk-GZ7HCLLM.js";
|
|
12
12
|
|
|
13
13
|
// transport/impls/uds/client.ts
|
|
@@ -23,7 +23,10 @@ var UnixDomainSocketClientTransport = class extends ClientTransport {
|
|
|
23
23
|
if (oldConnection) {
|
|
24
24
|
oldConnection.close();
|
|
25
25
|
}
|
|
26
|
-
log?.info(
|
|
26
|
+
log?.info(`establishing a new uds to ${to}`, {
|
|
27
|
+
clientId: this.clientId,
|
|
28
|
+
connectedTo: to
|
|
29
|
+
});
|
|
27
30
|
const sock = await new Promise((resolve, reject) => {
|
|
28
31
|
const sock2 = new Socket();
|
|
29
32
|
sock2.on("connect", () => resolve(sock2));
|