@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
|
@@ -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 {
|
|
@@ -906,18 +948,22 @@ var ClientTransport = class extends Transport {
|
|
|
906
948
|
if (session) {
|
|
907
949
|
this.onDisconnect(conn, session);
|
|
908
950
|
}
|
|
909
|
-
log?.info(
|
|
910
|
-
|
|
911
|
-
|
|
951
|
+
log?.info(`connection to ${to} disconnected`, {
|
|
952
|
+
...session?.loggingMetadata,
|
|
953
|
+
clientId: this.clientId,
|
|
954
|
+
connectedTo: to
|
|
955
|
+
});
|
|
912
956
|
this.inflightConnectionPromises.delete(to);
|
|
913
957
|
if (this.reconnectOnConnectionDrop) {
|
|
914
958
|
void this.connect(to);
|
|
915
959
|
}
|
|
916
960
|
});
|
|
917
961
|
conn.addErrorListener((err) => {
|
|
918
|
-
log?.warn(
|
|
919
|
-
|
|
920
|
-
|
|
962
|
+
log?.warn(`error in connection to ${to}: ${coerceErrorString(err)}`, {
|
|
963
|
+
...session?.loggingMetadata,
|
|
964
|
+
clientId: this.clientId,
|
|
965
|
+
connectedTo: to
|
|
966
|
+
});
|
|
921
967
|
});
|
|
922
968
|
}
|
|
923
969
|
receiveHandshakeResponseMessage(data, conn) {
|
|
@@ -930,11 +976,11 @@ var ClientTransport = class extends Transport {
|
|
|
930
976
|
return false;
|
|
931
977
|
}
|
|
932
978
|
if (!import_value.Value.Check(ControlMessageHandshakeResponseSchema, parsed.payload)) {
|
|
933
|
-
log?.warn(
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
);
|
|
979
|
+
log?.warn(`received invalid handshake resp`, {
|
|
980
|
+
clientId: this.clientId,
|
|
981
|
+
connectedTo: parsed.from,
|
|
982
|
+
fullTransportMessage: parsed
|
|
983
|
+
});
|
|
938
984
|
this.protocolError(
|
|
939
985
|
ProtocolError.HandshakeFailed,
|
|
940
986
|
"invalid handshake resp"
|
|
@@ -942,18 +988,22 @@ var ClientTransport = class extends Transport {
|
|
|
942
988
|
return false;
|
|
943
989
|
}
|
|
944
990
|
if (!parsed.payload.status.ok) {
|
|
945
|
-
log?.warn(
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
);
|
|
991
|
+
log?.warn(`received invalid handshake resp`, {
|
|
992
|
+
clientId: this.clientId,
|
|
993
|
+
connectedTo: parsed.from,
|
|
994
|
+
fullTransportMessage: parsed
|
|
995
|
+
});
|
|
950
996
|
this.protocolError(
|
|
951
997
|
ProtocolError.HandshakeFailed,
|
|
952
998
|
parsed.payload.status.reason
|
|
953
999
|
);
|
|
954
1000
|
return false;
|
|
955
1001
|
}
|
|
956
|
-
log?.debug(
|
|
1002
|
+
log?.debug(`handshake from ${parsed.from} ok`, {
|
|
1003
|
+
clientId: this.clientId,
|
|
1004
|
+
connectedTo: parsed.from,
|
|
1005
|
+
fullTransportMessage: parsed
|
|
1006
|
+
});
|
|
957
1007
|
const session = this.onConnect(
|
|
958
1008
|
conn,
|
|
959
1009
|
parsed.from,
|
|
@@ -970,7 +1020,8 @@ var ClientTransport = class extends Transport {
|
|
|
970
1020
|
const canProceedWithConnection = () => this.state === "open";
|
|
971
1021
|
if (!canProceedWithConnection()) {
|
|
972
1022
|
log?.info(
|
|
973
|
-
|
|
1023
|
+
`transport state is no longer open, cancelling attempt to connect to ${to}`,
|
|
1024
|
+
{ clientId: this.clientId, connectedTo: to }
|
|
974
1025
|
);
|
|
975
1026
|
return;
|
|
976
1027
|
}
|
|
@@ -979,7 +1030,7 @@ var ClientTransport = class extends Transport {
|
|
|
979
1030
|
const budgetConsumed = this.retryBudget.getBudgetConsumed(to);
|
|
980
1031
|
if (!this.retryBudget.hasBudget(to)) {
|
|
981
1032
|
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(
|
|
1033
|
+
log?.warn(errMsg, { clientId: this.clientId, connectedTo: to });
|
|
983
1034
|
this.protocolError(ProtocolError.RetriesExceeded, errMsg);
|
|
984
1035
|
return;
|
|
985
1036
|
}
|
|
@@ -988,9 +1039,10 @@ var ClientTransport = class extends Transport {
|
|
|
988
1039
|
if (backoffMs > 0) {
|
|
989
1040
|
sleep = new Promise((resolve) => setTimeout(resolve, backoffMs));
|
|
990
1041
|
}
|
|
991
|
-
log?.info(
|
|
992
|
-
|
|
993
|
-
|
|
1042
|
+
log?.info(`attempting connection to ${to} (${backoffMs}ms backoff)`, {
|
|
1043
|
+
clientId: this.clientId,
|
|
1044
|
+
connectedTo: to
|
|
1045
|
+
});
|
|
994
1046
|
this.retryBudget.consumeBudget(to);
|
|
995
1047
|
reconnectPromise = sleep.then(() => {
|
|
996
1048
|
if (!canProceedWithConnection()) {
|
|
@@ -999,7 +1051,12 @@ var ClientTransport = class extends Transport {
|
|
|
999
1051
|
}).then(() => this.createNewOutgoingConnection(to)).then((conn) => {
|
|
1000
1052
|
if (!canProceedWithConnection()) {
|
|
1001
1053
|
log?.info(
|
|
1002
|
-
|
|
1054
|
+
`transport state is no longer open, closing pre-handshake connection to ${to}`,
|
|
1055
|
+
{
|
|
1056
|
+
clientId: this.clientId,
|
|
1057
|
+
connectedTo: to,
|
|
1058
|
+
connId: conn.debugId
|
|
1059
|
+
}
|
|
1003
1060
|
);
|
|
1004
1061
|
conn.close();
|
|
1005
1062
|
throw new Error("transport state is no longer open");
|
|
@@ -1009,9 +1066,10 @@ var ClientTransport = class extends Transport {
|
|
|
1009
1066
|
});
|
|
1010
1067
|
this.inflightConnectionPromises.set(to, reconnectPromise);
|
|
1011
1068
|
} else {
|
|
1012
|
-
log?.info(
|
|
1013
|
-
|
|
1014
|
-
|
|
1069
|
+
log?.info(`attempting connection to ${to} (reusing previous attempt)`, {
|
|
1070
|
+
clientId: this.clientId,
|
|
1071
|
+
connectedTo: to
|
|
1072
|
+
});
|
|
1015
1073
|
}
|
|
1016
1074
|
try {
|
|
1017
1075
|
await reconnectPromise;
|
|
@@ -1019,11 +1077,15 @@ var ClientTransport = class extends Transport {
|
|
|
1019
1077
|
this.inflightConnectionPromises.delete(to);
|
|
1020
1078
|
const errStr = coerceErrorString(error);
|
|
1021
1079
|
if (!this.reconnectOnConnectionDrop || !canProceedWithConnection()) {
|
|
1022
|
-
log?.warn(
|
|
1080
|
+
log?.warn(`connection to ${to} failed (${errStr})`, {
|
|
1081
|
+
clientId: this.clientId,
|
|
1082
|
+
connectedTo: to
|
|
1083
|
+
});
|
|
1023
1084
|
} else {
|
|
1024
|
-
log?.warn(
|
|
1025
|
-
|
|
1026
|
-
|
|
1085
|
+
log?.warn(`connection to ${to} failed (${errStr}), retrying`, {
|
|
1086
|
+
clientId: this.clientId,
|
|
1087
|
+
connectedTo: to
|
|
1088
|
+
});
|
|
1027
1089
|
return this.connect(to);
|
|
1028
1090
|
}
|
|
1029
1091
|
}
|
|
@@ -1035,7 +1097,10 @@ var ClientTransport = class extends Transport {
|
|
|
1035
1097
|
sendHandshake(to, conn) {
|
|
1036
1098
|
const session = this.getOrCreateSession(to, conn);
|
|
1037
1099
|
const requestMsg = handshakeRequestMessage(this.clientId, to, session.id);
|
|
1038
|
-
log?.debug(
|
|
1100
|
+
log?.debug(`sending handshake request to ${to}`, {
|
|
1101
|
+
clientId: this.clientId,
|
|
1102
|
+
connectedTo: to
|
|
1103
|
+
});
|
|
1039
1104
|
conn.send(this.codec.toBuffer(requestMsg));
|
|
1040
1105
|
}
|
|
1041
1106
|
close() {
|
|
@@ -1056,7 +1121,10 @@ var UnixDomainSocketClientTransport = class extends ClientTransport {
|
|
|
1056
1121
|
if (oldConnection) {
|
|
1057
1122
|
oldConnection.close();
|
|
1058
1123
|
}
|
|
1059
|
-
log?.info(
|
|
1124
|
+
log?.info(`establishing a new uds to ${to}`, {
|
|
1125
|
+
clientId: this.clientId,
|
|
1126
|
+
connectedTo: to
|
|
1127
|
+
});
|
|
1060
1128
|
const sock = await new Promise((resolve, reject) => {
|
|
1061
1129
|
const sock2 = new import_node_net.Socket();
|
|
1062
1130
|
sock2.on("connect", () => resolve(sock2));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-314e676a.js';
|
|
2
|
+
import { T as TransportClientId } from '../../../index-6118cd48.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-32bf6608.js';
|
|
3
4
|
import '../../../types-3e5768ec.js';
|
|
4
5
|
import '@sinclair/typebox';
|
|
5
6
|
import 'node:net';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { b as ClientTransport, P as ProvidedClientTransportOptions } from '../../../index-314e676a.js';
|
|
2
|
+
import { T as TransportClientId } from '../../../index-6118cd48.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-32bf6608.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-ZPPKYJI7.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/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));
|