@replit/river 0.13.3 → 0.13.5
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/dist/{builder-d649690f.d.ts → builder-533e1324.d.ts} +2 -3
- package/dist/{chunk-FIX2F6VT.js → chunk-4JFIL3FG.js} +1 -1
- package/dist/{chunk-67M47YPQ.js → chunk-E2CP4UWB.js} +3 -4
- package/dist/{chunk-5V6B7TM3.js → chunk-MSJNWNYI.js} +1 -1
- package/dist/{chunk-MCTB3NYK.js → chunk-WYHD3FN7.js} +18 -18
- package/dist/{connection-6222fd0b.d.ts → connection-1f994b63.d.ts} +1 -1
- package/dist/{connection-2b55cc7f.d.ts → connection-f46114a1.d.ts} +1 -1
- package/dist/{index-1c1493df.d.ts → index-2154021c.d.ts} +4 -6
- package/dist/router/index.cjs +3 -4
- package/dist/router/index.d.cts +3 -3
- package/dist/router/index.d.ts +3 -3
- package/dist/router/index.js +1 -1
- package/dist/transport/impls/uds/client.cjs +13 -18
- package/dist/transport/impls/uds/client.d.cts +2 -2
- package/dist/transport/impls/uds/client.d.ts +2 -2
- package/dist/transport/impls/uds/client.js +2 -2
- package/dist/transport/impls/uds/server.cjs +16 -21
- package/dist/transport/impls/uds/server.d.cts +2 -2
- package/dist/transport/impls/uds/server.d.ts +2 -2
- package/dist/transport/impls/uds/server.js +2 -5
- package/dist/transport/impls/ws/client.cjs +13 -18
- package/dist/transport/impls/ws/client.d.cts +2 -2
- package/dist/transport/impls/ws/client.d.ts +2 -2
- package/dist/transport/impls/ws/client.js +2 -2
- package/dist/transport/impls/ws/server.cjs +19 -24
- package/dist/transport/impls/ws/server.d.cts +2 -2
- package/dist/transport/impls/ws/server.d.ts +2 -2
- package/dist/transport/impls/ws/server.js +3 -8
- package/dist/transport/index.cjs +18 -18
- package/dist/transport/index.d.cts +1 -1
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +1 -1
- package/dist/util/testHelpers.cjs +11 -18
- package/dist/util/testHelpers.d.cts +2 -2
- package/dist/util/testHelpers.d.ts +2 -2
- package/dist/util/testHelpers.js +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TObject, TUnion, TString, TSchema, TNever, TLiteral, Static } from '@sinclair/typebox';
|
|
2
2
|
import { Pushable } from 'it-pushable';
|
|
3
|
-
import { b as TransportClientId, d as Session, C as Connection } from './index-
|
|
3
|
+
import { b as TransportClientId, d as Session, C as Connection } from './index-2154021c.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The context for services/procedures. This is used only on
|
|
@@ -200,9 +200,8 @@ declare class ServiceBuilder<T extends Service<string, object, ProcListing>> {
|
|
|
200
200
|
private constructor();
|
|
201
201
|
/**
|
|
202
202
|
* Finalizes the schema for the service.
|
|
203
|
-
* @returns {T} The finalized schema for the service.
|
|
204
203
|
*/
|
|
205
|
-
finalize(): T
|
|
204
|
+
finalize(): Readonly<T>;
|
|
206
205
|
/**
|
|
207
206
|
* Sets the initial state for the service.
|
|
208
207
|
* @template InitState The type of the initial state.
|
|
@@ -41,10 +41,9 @@ var ServiceBuilder = class _ServiceBuilder {
|
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Finalizes the schema for the service.
|
|
44
|
-
* @returns {T} The finalized schema for the service.
|
|
45
44
|
*/
|
|
46
45
|
finalize() {
|
|
47
|
-
return this.schema;
|
|
46
|
+
return Object.freeze(this.schema);
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
49
|
* Sets the initial state for the service.
|
|
@@ -771,8 +770,8 @@ var RiverServer = class {
|
|
|
771
770
|
}
|
|
772
771
|
createNewProcStream(message) {
|
|
773
772
|
if (!isStreamOpen(message.controlFlags)) {
|
|
774
|
-
log?.
|
|
775
|
-
`${this.transport.clientId} --
|
|
773
|
+
log?.error(
|
|
774
|
+
`${this.transport.clientId} -- can't create a new procedure stream from a message that doesn't have the stream open bit set`
|
|
776
775
|
);
|
|
777
776
|
return;
|
|
778
777
|
}
|
|
@@ -118,12 +118,11 @@ var Session = class {
|
|
|
118
118
|
* If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
|
|
119
119
|
*
|
|
120
120
|
* @param msg The partial message to be sent, which will be constructed into a full message.
|
|
121
|
-
* @param
|
|
122
|
-
* ack hearbeats, which contain information that can already be found in the other buffered messages.
|
|
121
|
+
* @param addToSendBuff Whether to add the message to the send buffer for retry.
|
|
123
122
|
* @returns The full transport ID of the message that was attempted to be sent.
|
|
124
123
|
*/
|
|
125
|
-
send(msg,
|
|
126
|
-
const fullMsg = this.constructMsg(msg);
|
|
124
|
+
send(msg, addToSendBuff = true) {
|
|
125
|
+
const fullMsg = this.constructMsg(msg, addToSendBuff);
|
|
127
126
|
log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
|
|
128
127
|
if (this.connection) {
|
|
129
128
|
const ok = this.connection.send(this.codec.toBuffer(fullMsg));
|
|
@@ -137,12 +136,6 @@ var Session = class {
|
|
|
137
136
|
`${this.from} -- failed to send ${fullMsg.id} to ${fullMsg.to}, connection not ready yet`
|
|
138
137
|
);
|
|
139
138
|
}
|
|
140
|
-
if (skipRetry)
|
|
141
|
-
return fullMsg.id;
|
|
142
|
-
this.addToSendBuff(fullMsg);
|
|
143
|
-
log?.info(
|
|
144
|
-
`${this.from} -- buffering msg ${fullMsg.id} until connection is healthy again`
|
|
145
|
-
);
|
|
146
139
|
return fullMsg.id;
|
|
147
140
|
}
|
|
148
141
|
sendHeartbeat() {
|
|
@@ -163,7 +156,7 @@ var Session = class {
|
|
|
163
156
|
type: "ACK"
|
|
164
157
|
}
|
|
165
158
|
},
|
|
166
|
-
|
|
159
|
+
false
|
|
167
160
|
);
|
|
168
161
|
this.heartbeatMisses++;
|
|
169
162
|
}
|
|
@@ -178,6 +171,9 @@ var Session = class {
|
|
|
178
171
|
log?.error(msg);
|
|
179
172
|
throw new Error(msg);
|
|
180
173
|
}
|
|
174
|
+
log?.info(
|
|
175
|
+
`${this.from} -- resending ${this.sendBuffer.length} buffered messages`
|
|
176
|
+
);
|
|
181
177
|
for (const msg of this.sendBuffer) {
|
|
182
178
|
log?.debug(`${this.from} -- resending ${JSON.stringify(msg)}`);
|
|
183
179
|
const ok = this.connection.send(this.codec.toBuffer(msg));
|
|
@@ -192,12 +188,6 @@ var Session = class {
|
|
|
192
188
|
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq > ack);
|
|
193
189
|
this.ack = seq + 1;
|
|
194
190
|
}
|
|
195
|
-
addToSendBuff(msg) {
|
|
196
|
-
this.sendBuffer.push(msg);
|
|
197
|
-
log?.debug(
|
|
198
|
-
`${this.from} -- send buff to ${this.to} now tracking ${this.sendBuffer.length} messages`
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
191
|
closeStaleConnection(conn) {
|
|
202
192
|
if (!this.connection || this.connection !== conn)
|
|
203
193
|
return;
|
|
@@ -240,7 +230,7 @@ var Session = class {
|
|
|
240
230
|
get nextExpectedSeq() {
|
|
241
231
|
return this.ack;
|
|
242
232
|
}
|
|
243
|
-
constructMsg(partialMsg) {
|
|
233
|
+
constructMsg(partialMsg, addToSendBuff = true) {
|
|
244
234
|
const msg = {
|
|
245
235
|
...partialMsg,
|
|
246
236
|
id: unsafeId(),
|
|
@@ -250,6 +240,9 @@ var Session = class {
|
|
|
250
240
|
ack: this.ack
|
|
251
241
|
};
|
|
252
242
|
this.seq++;
|
|
243
|
+
if (addToSendBuff) {
|
|
244
|
+
this.sendBuffer.push(msg);
|
|
245
|
+
}
|
|
253
246
|
return msg;
|
|
254
247
|
}
|
|
255
248
|
inspectSendBuffer() {
|
|
@@ -549,6 +542,8 @@ var ClientTransport = class extends Transport {
|
|
|
549
542
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
550
543
|
}
|
|
551
544
|
handleConnection(conn, to) {
|
|
545
|
+
if (this.state !== "open")
|
|
546
|
+
return;
|
|
552
547
|
let session = void 0;
|
|
553
548
|
const handshakeHandler = (data) => {
|
|
554
549
|
const handshake = this.receiveHandshakeResponseMessage(data);
|
|
@@ -667,6 +662,11 @@ var ServerTransport = class extends Transport {
|
|
|
667
662
|
);
|
|
668
663
|
}
|
|
669
664
|
handleConnection(conn) {
|
|
665
|
+
if (this.state !== "open")
|
|
666
|
+
return;
|
|
667
|
+
log?.info(
|
|
668
|
+
`${this.clientId} -- new incoming connection (id: ${conn.debugId})`
|
|
669
|
+
);
|
|
670
670
|
let session = void 0;
|
|
671
671
|
const client = () => session?.to ?? "unknown";
|
|
672
672
|
const handshakeHandler = (data) => {
|
|
@@ -185,16 +185,14 @@ declare class Session<ConnType extends Connection> {
|
|
|
185
185
|
* If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
|
|
186
186
|
*
|
|
187
187
|
* @param msg The partial message to be sent, which will be constructed into a full message.
|
|
188
|
-
* @param
|
|
189
|
-
* ack hearbeats, which contain information that can already be found in the other buffered messages.
|
|
188
|
+
* @param addToSendBuff Whether to add the message to the send buffer for retry.
|
|
190
189
|
* @returns The full transport ID of the message that was attempted to be sent.
|
|
191
190
|
*/
|
|
192
|
-
send(msg: PartialTransportMessage,
|
|
191
|
+
send(msg: PartialTransportMessage, addToSendBuff?: boolean): string;
|
|
193
192
|
sendHeartbeat(): void;
|
|
194
193
|
resetBufferedMessages(): void;
|
|
195
194
|
sendBufferedMessages(): void;
|
|
196
195
|
updateBookkeeping(ack: number, seq: number): void;
|
|
197
|
-
addToSendBuff(msg: TransportMessage): void;
|
|
198
196
|
closeStaleConnection(conn?: ConnType): void;
|
|
199
197
|
replaceWithNewConnection(newConn: ConnType): void;
|
|
200
198
|
beginGrace(cb: () => void): void;
|
|
@@ -202,7 +200,7 @@ declare class Session<ConnType extends Connection> {
|
|
|
202
200
|
close(): void;
|
|
203
201
|
get connected(): boolean;
|
|
204
202
|
get nextExpectedSeq(): number;
|
|
205
|
-
constructMsg<Payload extends Record<string, unknown>>(partialMsg: PartialTransportMessage<Payload
|
|
203
|
+
constructMsg<Payload extends Record<string, unknown>>(partialMsg: PartialTransportMessage<Payload>, addToSendBuff?: boolean): TransportMessage<Payload>;
|
|
206
204
|
inspectSendBuffer(): ReadonlyArray<OpaqueTransportMessage>;
|
|
207
205
|
}
|
|
208
206
|
|
|
@@ -421,4 +419,4 @@ declare abstract class ServerTransport<ConnType extends Connection> extends Tran
|
|
|
421
419
|
};
|
|
422
420
|
}
|
|
423
421
|
|
|
424
|
-
export { Connection as C, EventMap as E, OpaqueTransportMessage as O, PartialTransportMessage as P, ServerTransport as S, Transport as T, ClientTransport as a, TransportClientId as b, TransportOptions as c, Session as d,
|
|
422
|
+
export { Connection as C, EventMap as E, OpaqueTransportMessage as O, PartialTransportMessage as P, ServerTransport as S, Transport as T, ClientTransport as a, TransportClientId as b, TransportOptions as c, Session as d, TransportStatus as e, TransportMessageSchema as f, OpaqueTransportMessageSchema as g, TransportMessage as h, isStreamOpen as i, isStreamClose as j, EventTypes as k, EventHandler as l };
|
package/dist/router/index.cjs
CHANGED
|
@@ -65,10 +65,9 @@ var ServiceBuilder = class _ServiceBuilder {
|
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Finalizes the schema for the service.
|
|
68
|
-
* @returns {T} The finalized schema for the service.
|
|
69
68
|
*/
|
|
70
69
|
finalize() {
|
|
71
|
-
return this.schema;
|
|
70
|
+
return Object.freeze(this.schema);
|
|
72
71
|
}
|
|
73
72
|
/**
|
|
74
73
|
* Sets the initial state for the service.
|
|
@@ -867,8 +866,8 @@ var RiverServer = class {
|
|
|
867
866
|
}
|
|
868
867
|
createNewProcStream(message) {
|
|
869
868
|
if (!isStreamOpen(message.controlFlags)) {
|
|
870
|
-
log?.
|
|
871
|
-
`${this.transport.clientId} --
|
|
869
|
+
log?.error(
|
|
870
|
+
`${this.transport.clientId} -- can't create a new procedure stream from a message that doesn't have the stream open bit set`
|
|
872
871
|
);
|
|
873
872
|
return;
|
|
874
873
|
}
|
package/dist/router/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-
|
|
2
|
-
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-
|
|
3
|
-
import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-
|
|
1
|
+
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-533e1324.js';
|
|
2
|
+
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-533e1324.js';
|
|
3
|
+
import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-2154021c.js';
|
|
4
4
|
import { Pushable } from 'it-pushable';
|
|
5
5
|
import { Static } from '@sinclair/typebox';
|
|
6
6
|
import '../types-3e5768ec.js';
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-
|
|
2
|
-
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-
|
|
3
|
-
import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-
|
|
1
|
+
import { A as AnyService, P as PayloadType, b as Result, R as RiverError, S as ServiceContext, d as ProcType, e as ProcInput, f as ProcOutput, g as ProcErrors, h as ProcHasInit, i as ProcInit } from '../builder-533e1324.js';
|
|
2
|
+
export { E as Err, O as Ok, m as ProcHandler, k as ProcListing, a as Procedure, p as RiverErrorSchema, c as RiverUncaughtSchema, l as Service, j as ServiceBuilder, n as ServiceContextWithState, o as ServiceContextWithTransportInfo, U as UNCAUGHT_ERROR, V as ValidProcType, s as serializeService } from '../builder-533e1324.js';
|
|
3
|
+
import { S as ServerTransport, C as Connection, a as ClientTransport } from '../index-2154021c.js';
|
|
4
4
|
import { Pushable } from 'it-pushable';
|
|
5
5
|
import { Static } from '@sinclair/typebox';
|
|
6
6
|
import '../types-3e5768ec.js';
|
package/dist/router/index.js
CHANGED
|
@@ -226,12 +226,11 @@ var Session = class {
|
|
|
226
226
|
* If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
|
|
227
227
|
*
|
|
228
228
|
* @param msg The partial message to be sent, which will be constructed into a full message.
|
|
229
|
-
* @param
|
|
230
|
-
* ack hearbeats, which contain information that can already be found in the other buffered messages.
|
|
229
|
+
* @param addToSendBuff Whether to add the message to the send buffer for retry.
|
|
231
230
|
* @returns The full transport ID of the message that was attempted to be sent.
|
|
232
231
|
*/
|
|
233
|
-
send(msg,
|
|
234
|
-
const fullMsg = this.constructMsg(msg);
|
|
232
|
+
send(msg, addToSendBuff = true) {
|
|
233
|
+
const fullMsg = this.constructMsg(msg, addToSendBuff);
|
|
235
234
|
log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
|
|
236
235
|
if (this.connection) {
|
|
237
236
|
const ok = this.connection.send(this.codec.toBuffer(fullMsg));
|
|
@@ -245,12 +244,6 @@ var Session = class {
|
|
|
245
244
|
`${this.from} -- failed to send ${fullMsg.id} to ${fullMsg.to}, connection not ready yet`
|
|
246
245
|
);
|
|
247
246
|
}
|
|
248
|
-
if (skipRetry)
|
|
249
|
-
return fullMsg.id;
|
|
250
|
-
this.addToSendBuff(fullMsg);
|
|
251
|
-
log?.info(
|
|
252
|
-
`${this.from} -- buffering msg ${fullMsg.id} until connection is healthy again`
|
|
253
|
-
);
|
|
254
247
|
return fullMsg.id;
|
|
255
248
|
}
|
|
256
249
|
sendHeartbeat() {
|
|
@@ -271,7 +264,7 @@ var Session = class {
|
|
|
271
264
|
type: "ACK"
|
|
272
265
|
}
|
|
273
266
|
},
|
|
274
|
-
|
|
267
|
+
false
|
|
275
268
|
);
|
|
276
269
|
this.heartbeatMisses++;
|
|
277
270
|
}
|
|
@@ -286,6 +279,9 @@ var Session = class {
|
|
|
286
279
|
log?.error(msg);
|
|
287
280
|
throw new Error(msg);
|
|
288
281
|
}
|
|
282
|
+
log?.info(
|
|
283
|
+
`${this.from} -- resending ${this.sendBuffer.length} buffered messages`
|
|
284
|
+
);
|
|
289
285
|
for (const msg of this.sendBuffer) {
|
|
290
286
|
log?.debug(`${this.from} -- resending ${JSON.stringify(msg)}`);
|
|
291
287
|
const ok = this.connection.send(this.codec.toBuffer(msg));
|
|
@@ -300,12 +296,6 @@ var Session = class {
|
|
|
300
296
|
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq > ack);
|
|
301
297
|
this.ack = seq + 1;
|
|
302
298
|
}
|
|
303
|
-
addToSendBuff(msg) {
|
|
304
|
-
this.sendBuffer.push(msg);
|
|
305
|
-
log?.debug(
|
|
306
|
-
`${this.from} -- send buff to ${this.to} now tracking ${this.sendBuffer.length} messages`
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
299
|
closeStaleConnection(conn) {
|
|
310
300
|
if (!this.connection || this.connection !== conn)
|
|
311
301
|
return;
|
|
@@ -348,7 +338,7 @@ var Session = class {
|
|
|
348
338
|
get nextExpectedSeq() {
|
|
349
339
|
return this.ack;
|
|
350
340
|
}
|
|
351
|
-
constructMsg(partialMsg) {
|
|
341
|
+
constructMsg(partialMsg, addToSendBuff = true) {
|
|
352
342
|
const msg = {
|
|
353
343
|
...partialMsg,
|
|
354
344
|
id: unsafeId(),
|
|
@@ -358,6 +348,9 @@ var Session = class {
|
|
|
358
348
|
ack: this.ack
|
|
359
349
|
};
|
|
360
350
|
this.seq++;
|
|
351
|
+
if (addToSendBuff) {
|
|
352
|
+
this.sendBuffer.push(msg);
|
|
353
|
+
}
|
|
361
354
|
return msg;
|
|
362
355
|
}
|
|
363
356
|
inspectSendBuffer() {
|
|
@@ -790,6 +783,8 @@ var ClientTransport = class extends Transport {
|
|
|
790
783
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
791
784
|
}
|
|
792
785
|
handleConnection(conn, to) {
|
|
786
|
+
if (this.state !== "open")
|
|
787
|
+
return;
|
|
793
788
|
let session = void 0;
|
|
794
789
|
const handshakeHandler = (data) => {
|
|
795
790
|
const handshake = this.receiveHandshakeResponseMessage(data);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-1f994b63.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-1f994b63.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-4JFIL3FG.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-WYHD3FN7.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -264,12 +264,11 @@ var Session = class {
|
|
|
264
264
|
* If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
|
|
265
265
|
*
|
|
266
266
|
* @param msg The partial message to be sent, which will be constructed into a full message.
|
|
267
|
-
* @param
|
|
268
|
-
* ack hearbeats, which contain information that can already be found in the other buffered messages.
|
|
267
|
+
* @param addToSendBuff Whether to add the message to the send buffer for retry.
|
|
269
268
|
* @returns The full transport ID of the message that was attempted to be sent.
|
|
270
269
|
*/
|
|
271
|
-
send(msg,
|
|
272
|
-
const fullMsg = this.constructMsg(msg);
|
|
270
|
+
send(msg, addToSendBuff = true) {
|
|
271
|
+
const fullMsg = this.constructMsg(msg, addToSendBuff);
|
|
273
272
|
log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
|
|
274
273
|
if (this.connection) {
|
|
275
274
|
const ok = this.connection.send(this.codec.toBuffer(fullMsg));
|
|
@@ -283,12 +282,6 @@ var Session = class {
|
|
|
283
282
|
`${this.from} -- failed to send ${fullMsg.id} to ${fullMsg.to}, connection not ready yet`
|
|
284
283
|
);
|
|
285
284
|
}
|
|
286
|
-
if (skipRetry)
|
|
287
|
-
return fullMsg.id;
|
|
288
|
-
this.addToSendBuff(fullMsg);
|
|
289
|
-
log?.info(
|
|
290
|
-
`${this.from} -- buffering msg ${fullMsg.id} until connection is healthy again`
|
|
291
|
-
);
|
|
292
285
|
return fullMsg.id;
|
|
293
286
|
}
|
|
294
287
|
sendHeartbeat() {
|
|
@@ -309,7 +302,7 @@ var Session = class {
|
|
|
309
302
|
type: "ACK"
|
|
310
303
|
}
|
|
311
304
|
},
|
|
312
|
-
|
|
305
|
+
false
|
|
313
306
|
);
|
|
314
307
|
this.heartbeatMisses++;
|
|
315
308
|
}
|
|
@@ -324,6 +317,9 @@ var Session = class {
|
|
|
324
317
|
log?.error(msg);
|
|
325
318
|
throw new Error(msg);
|
|
326
319
|
}
|
|
320
|
+
log?.info(
|
|
321
|
+
`${this.from} -- resending ${this.sendBuffer.length} buffered messages`
|
|
322
|
+
);
|
|
327
323
|
for (const msg of this.sendBuffer) {
|
|
328
324
|
log?.debug(`${this.from} -- resending ${JSON.stringify(msg)}`);
|
|
329
325
|
const ok = this.connection.send(this.codec.toBuffer(msg));
|
|
@@ -338,12 +334,6 @@ var Session = class {
|
|
|
338
334
|
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq > ack);
|
|
339
335
|
this.ack = seq + 1;
|
|
340
336
|
}
|
|
341
|
-
addToSendBuff(msg) {
|
|
342
|
-
this.sendBuffer.push(msg);
|
|
343
|
-
log?.debug(
|
|
344
|
-
`${this.from} -- send buff to ${this.to} now tracking ${this.sendBuffer.length} messages`
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
337
|
closeStaleConnection(conn) {
|
|
348
338
|
if (!this.connection || this.connection !== conn)
|
|
349
339
|
return;
|
|
@@ -386,7 +376,7 @@ var Session = class {
|
|
|
386
376
|
get nextExpectedSeq() {
|
|
387
377
|
return this.ack;
|
|
388
378
|
}
|
|
389
|
-
constructMsg(partialMsg) {
|
|
379
|
+
constructMsg(partialMsg, addToSendBuff = true) {
|
|
390
380
|
const msg = {
|
|
391
381
|
...partialMsg,
|
|
392
382
|
id: unsafeId(),
|
|
@@ -396,6 +386,9 @@ var Session = class {
|
|
|
396
386
|
ack: this.ack
|
|
397
387
|
};
|
|
398
388
|
this.seq++;
|
|
389
|
+
if (addToSendBuff) {
|
|
390
|
+
this.sendBuffer.push(msg);
|
|
391
|
+
}
|
|
399
392
|
return msg;
|
|
400
393
|
}
|
|
401
394
|
inspectSendBuffer() {
|
|
@@ -699,6 +692,11 @@ var ServerTransport = class extends Transport {
|
|
|
699
692
|
);
|
|
700
693
|
}
|
|
701
694
|
handleConnection(conn) {
|
|
695
|
+
if (this.state !== "open")
|
|
696
|
+
return;
|
|
697
|
+
log?.info(
|
|
698
|
+
`${this.clientId} -- new incoming connection (id: ${conn.debugId})`
|
|
699
|
+
);
|
|
702
700
|
let session = void 0;
|
|
703
701
|
const client = () => session?.to ?? "unknown";
|
|
704
702
|
const handshakeHandler = (data) => {
|
|
@@ -890,9 +888,6 @@ var UnixDomainSocketServerTransport = class extends ServerTransport {
|
|
|
890
888
|
connectionHandler = (sock) => {
|
|
891
889
|
const conn = new UdsConnection(sock);
|
|
892
890
|
this.handleConnection(conn);
|
|
893
|
-
log?.info(
|
|
894
|
-
`${this.clientId} -- new incoming uds connection (id: ${conn.debugId})`
|
|
895
|
-
);
|
|
896
891
|
};
|
|
897
892
|
close() {
|
|
898
893
|
super.close();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server, Socket } from 'node:net';
|
|
2
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { U as UdsConnection } from '../../../connection-
|
|
2
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-1f994b63.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'node:stream';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server, Socket } from 'node:net';
|
|
2
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { U as UdsConnection } from '../../../connection-
|
|
2
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-1f994b63.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'node:stream';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-4JFIL3FG.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-WYHD3FN7.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -24,9 +24,6 @@ var UnixDomainSocketServerTransport = class extends ServerTransport {
|
|
|
24
24
|
connectionHandler = (sock) => {
|
|
25
25
|
const conn = new UdsConnection(sock);
|
|
26
26
|
this.handleConnection(conn);
|
|
27
|
-
log?.info(
|
|
28
|
-
`${this.clientId} -- new incoming uds connection (id: ${conn.debugId})`
|
|
29
|
-
);
|
|
30
27
|
};
|
|
31
28
|
close() {
|
|
32
29
|
super.close();
|
|
@@ -256,12 +256,11 @@ var Session = class {
|
|
|
256
256
|
* If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
|
|
257
257
|
*
|
|
258
258
|
* @param msg The partial message to be sent, which will be constructed into a full message.
|
|
259
|
-
* @param
|
|
260
|
-
* ack hearbeats, which contain information that can already be found in the other buffered messages.
|
|
259
|
+
* @param addToSendBuff Whether to add the message to the send buffer for retry.
|
|
261
260
|
* @returns The full transport ID of the message that was attempted to be sent.
|
|
262
261
|
*/
|
|
263
|
-
send(msg,
|
|
264
|
-
const fullMsg = this.constructMsg(msg);
|
|
262
|
+
send(msg, addToSendBuff = true) {
|
|
263
|
+
const fullMsg = this.constructMsg(msg, addToSendBuff);
|
|
265
264
|
log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
|
|
266
265
|
if (this.connection) {
|
|
267
266
|
const ok = this.connection.send(this.codec.toBuffer(fullMsg));
|
|
@@ -275,12 +274,6 @@ var Session = class {
|
|
|
275
274
|
`${this.from} -- failed to send ${fullMsg.id} to ${fullMsg.to}, connection not ready yet`
|
|
276
275
|
);
|
|
277
276
|
}
|
|
278
|
-
if (skipRetry)
|
|
279
|
-
return fullMsg.id;
|
|
280
|
-
this.addToSendBuff(fullMsg);
|
|
281
|
-
log?.info(
|
|
282
|
-
`${this.from} -- buffering msg ${fullMsg.id} until connection is healthy again`
|
|
283
|
-
);
|
|
284
277
|
return fullMsg.id;
|
|
285
278
|
}
|
|
286
279
|
sendHeartbeat() {
|
|
@@ -301,7 +294,7 @@ var Session = class {
|
|
|
301
294
|
type: "ACK"
|
|
302
295
|
}
|
|
303
296
|
},
|
|
304
|
-
|
|
297
|
+
false
|
|
305
298
|
);
|
|
306
299
|
this.heartbeatMisses++;
|
|
307
300
|
}
|
|
@@ -316,6 +309,9 @@ var Session = class {
|
|
|
316
309
|
log?.error(msg);
|
|
317
310
|
throw new Error(msg);
|
|
318
311
|
}
|
|
312
|
+
log?.info(
|
|
313
|
+
`${this.from} -- resending ${this.sendBuffer.length} buffered messages`
|
|
314
|
+
);
|
|
319
315
|
for (const msg of this.sendBuffer) {
|
|
320
316
|
log?.debug(`${this.from} -- resending ${JSON.stringify(msg)}`);
|
|
321
317
|
const ok = this.connection.send(this.codec.toBuffer(msg));
|
|
@@ -330,12 +326,6 @@ var Session = class {
|
|
|
330
326
|
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq > ack);
|
|
331
327
|
this.ack = seq + 1;
|
|
332
328
|
}
|
|
333
|
-
addToSendBuff(msg) {
|
|
334
|
-
this.sendBuffer.push(msg);
|
|
335
|
-
log?.debug(
|
|
336
|
-
`${this.from} -- send buff to ${this.to} now tracking ${this.sendBuffer.length} messages`
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
329
|
closeStaleConnection(conn) {
|
|
340
330
|
if (!this.connection || this.connection !== conn)
|
|
341
331
|
return;
|
|
@@ -378,7 +368,7 @@ var Session = class {
|
|
|
378
368
|
get nextExpectedSeq() {
|
|
379
369
|
return this.ack;
|
|
380
370
|
}
|
|
381
|
-
constructMsg(partialMsg) {
|
|
371
|
+
constructMsg(partialMsg, addToSendBuff = true) {
|
|
382
372
|
const msg = {
|
|
383
373
|
...partialMsg,
|
|
384
374
|
id: unsafeId(),
|
|
@@ -388,6 +378,9 @@ var Session = class {
|
|
|
388
378
|
ack: this.ack
|
|
389
379
|
};
|
|
390
380
|
this.seq++;
|
|
381
|
+
if (addToSendBuff) {
|
|
382
|
+
this.sendBuffer.push(msg);
|
|
383
|
+
}
|
|
391
384
|
return msg;
|
|
392
385
|
}
|
|
393
386
|
inspectSendBuffer() {
|
|
@@ -696,6 +689,8 @@ var ClientTransport = class extends Transport {
|
|
|
696
689
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
697
690
|
}
|
|
698
691
|
handleConnection(conn, to) {
|
|
692
|
+
if (this.state !== "open")
|
|
693
|
+
return;
|
|
699
694
|
let session = void 0;
|
|
700
695
|
const handshakeHandler = (data) => {
|
|
701
696
|
const handshake = this.receiveHandshakeResponseMessage(data);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
|
-
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
2
|
+
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-f46114a1.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebSocket from 'isomorphic-ws';
|
|
2
|
-
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
3
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
2
|
+
import { a as ClientTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-f46114a1.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-MSJNWNYI.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-WYHD3FN7.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -24,9 +24,6 @@ __export(server_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(server_exports);
|
|
26
26
|
|
|
27
|
-
// logging/index.ts
|
|
28
|
-
var log;
|
|
29
|
-
|
|
30
27
|
// transport/transport.ts
|
|
31
28
|
var import_value = require("@sinclair/typebox/value");
|
|
32
29
|
|
|
@@ -107,6 +104,9 @@ function isAck(controlFlag) {
|
|
|
107
104
|
return (controlFlag & 1 /* AckBit */) === 1 /* AckBit */;
|
|
108
105
|
}
|
|
109
106
|
|
|
107
|
+
// logging/index.ts
|
|
108
|
+
var log;
|
|
109
|
+
|
|
110
110
|
// transport/events.ts
|
|
111
111
|
var EventDispatcher = class {
|
|
112
112
|
eventListeners = {};
|
|
@@ -264,12 +264,11 @@ var Session = class {
|
|
|
264
264
|
* If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
|
|
265
265
|
*
|
|
266
266
|
* @param msg The partial message to be sent, which will be constructed into a full message.
|
|
267
|
-
* @param
|
|
268
|
-
* ack hearbeats, which contain information that can already be found in the other buffered messages.
|
|
267
|
+
* @param addToSendBuff Whether to add the message to the send buffer for retry.
|
|
269
268
|
* @returns The full transport ID of the message that was attempted to be sent.
|
|
270
269
|
*/
|
|
271
|
-
send(msg,
|
|
272
|
-
const fullMsg = this.constructMsg(msg);
|
|
270
|
+
send(msg, addToSendBuff = true) {
|
|
271
|
+
const fullMsg = this.constructMsg(msg, addToSendBuff);
|
|
273
272
|
log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
|
|
274
273
|
if (this.connection) {
|
|
275
274
|
const ok = this.connection.send(this.codec.toBuffer(fullMsg));
|
|
@@ -283,12 +282,6 @@ var Session = class {
|
|
|
283
282
|
`${this.from} -- failed to send ${fullMsg.id} to ${fullMsg.to}, connection not ready yet`
|
|
284
283
|
);
|
|
285
284
|
}
|
|
286
|
-
if (skipRetry)
|
|
287
|
-
return fullMsg.id;
|
|
288
|
-
this.addToSendBuff(fullMsg);
|
|
289
|
-
log?.info(
|
|
290
|
-
`${this.from} -- buffering msg ${fullMsg.id} until connection is healthy again`
|
|
291
|
-
);
|
|
292
285
|
return fullMsg.id;
|
|
293
286
|
}
|
|
294
287
|
sendHeartbeat() {
|
|
@@ -309,7 +302,7 @@ var Session = class {
|
|
|
309
302
|
type: "ACK"
|
|
310
303
|
}
|
|
311
304
|
},
|
|
312
|
-
|
|
305
|
+
false
|
|
313
306
|
);
|
|
314
307
|
this.heartbeatMisses++;
|
|
315
308
|
}
|
|
@@ -324,6 +317,9 @@ var Session = class {
|
|
|
324
317
|
log?.error(msg);
|
|
325
318
|
throw new Error(msg);
|
|
326
319
|
}
|
|
320
|
+
log?.info(
|
|
321
|
+
`${this.from} -- resending ${this.sendBuffer.length} buffered messages`
|
|
322
|
+
);
|
|
327
323
|
for (const msg of this.sendBuffer) {
|
|
328
324
|
log?.debug(`${this.from} -- resending ${JSON.stringify(msg)}`);
|
|
329
325
|
const ok = this.connection.send(this.codec.toBuffer(msg));
|
|
@@ -338,12 +334,6 @@ var Session = class {
|
|
|
338
334
|
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq > ack);
|
|
339
335
|
this.ack = seq + 1;
|
|
340
336
|
}
|
|
341
|
-
addToSendBuff(msg) {
|
|
342
|
-
this.sendBuffer.push(msg);
|
|
343
|
-
log?.debug(
|
|
344
|
-
`${this.from} -- send buff to ${this.to} now tracking ${this.sendBuffer.length} messages`
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
337
|
closeStaleConnection(conn) {
|
|
348
338
|
if (!this.connection || this.connection !== conn)
|
|
349
339
|
return;
|
|
@@ -386,7 +376,7 @@ var Session = class {
|
|
|
386
376
|
get nextExpectedSeq() {
|
|
387
377
|
return this.ack;
|
|
388
378
|
}
|
|
389
|
-
constructMsg(partialMsg) {
|
|
379
|
+
constructMsg(partialMsg, addToSendBuff = true) {
|
|
390
380
|
const msg = {
|
|
391
381
|
...partialMsg,
|
|
392
382
|
id: unsafeId(),
|
|
@@ -396,6 +386,9 @@ var Session = class {
|
|
|
396
386
|
ack: this.ack
|
|
397
387
|
};
|
|
398
388
|
this.seq++;
|
|
389
|
+
if (addToSendBuff) {
|
|
390
|
+
this.sendBuffer.push(msg);
|
|
391
|
+
}
|
|
399
392
|
return msg;
|
|
400
393
|
}
|
|
401
394
|
inspectSendBuffer() {
|
|
@@ -699,6 +692,11 @@ var ServerTransport = class extends Transport {
|
|
|
699
692
|
);
|
|
700
693
|
}
|
|
701
694
|
handleConnection(conn) {
|
|
695
|
+
if (this.state !== "open")
|
|
696
|
+
return;
|
|
697
|
+
log?.info(
|
|
698
|
+
`${this.clientId} -- new incoming connection (id: ${conn.debugId})`
|
|
699
|
+
);
|
|
702
700
|
let session = void 0;
|
|
703
701
|
const client = () => session?.to ?? "unknown";
|
|
704
702
|
const handshakeHandler = (data) => {
|
|
@@ -826,9 +824,6 @@ var WebSocketServerTransport = class extends ServerTransport {
|
|
|
826
824
|
}
|
|
827
825
|
connectionHandler = (ws) => {
|
|
828
826
|
const conn = new WebSocketConnection(ws);
|
|
829
|
-
log?.info(
|
|
830
|
-
`${this.clientId} -- new incoming ws connection (id: ${conn.debugId})`
|
|
831
|
-
);
|
|
832
827
|
this.handleConnection(conn);
|
|
833
828
|
};
|
|
834
829
|
close() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
1
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
|
|
2
2
|
import { WebSocketServer } from 'ws';
|
|
3
3
|
import { WebSocket } from 'isomorphic-ws';
|
|
4
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-f46114a1.js';
|
|
5
5
|
import '../../../types-3e5768ec.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-
|
|
1
|
+
import { S as ServerTransport, b as TransportClientId, c as TransportOptions } from '../../../index-2154021c.js';
|
|
2
2
|
import { WebSocketServer } from 'ws';
|
|
3
3
|
import { WebSocket } from 'isomorphic-ws';
|
|
4
|
-
import { W as WebSocketConnection } from '../../../connection-
|
|
4
|
+
import { W as WebSocketConnection } from '../../../connection-f46114a1.js';
|
|
5
5
|
import '../../../types-3e5768ec.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-MSJNWNYI.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-WYHD3FN7.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
|
-
import
|
|
9
|
-
log
|
|
10
|
-
} from "../../../chunk-H4BYJELI.js";
|
|
8
|
+
import "../../../chunk-H4BYJELI.js";
|
|
11
9
|
import "../../../chunk-GZ7HCLLM.js";
|
|
12
10
|
|
|
13
11
|
// transport/impls/ws/server.ts
|
|
@@ -20,9 +18,6 @@ var WebSocketServerTransport = class extends ServerTransport {
|
|
|
20
18
|
}
|
|
21
19
|
connectionHandler = (ws) => {
|
|
22
20
|
const conn = new WebSocketConnection(ws);
|
|
23
|
-
log?.info(
|
|
24
|
-
`${this.clientId} -- new incoming ws connection (id: ${conn.debugId})`
|
|
25
|
-
);
|
|
26
21
|
this.handleConnection(conn);
|
|
27
22
|
};
|
|
28
23
|
close() {
|
package/dist/transport/index.cjs
CHANGED
|
@@ -286,12 +286,11 @@ var Session = class {
|
|
|
286
286
|
* If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
|
|
287
287
|
*
|
|
288
288
|
* @param msg The partial message to be sent, which will be constructed into a full message.
|
|
289
|
-
* @param
|
|
290
|
-
* ack hearbeats, which contain information that can already be found in the other buffered messages.
|
|
289
|
+
* @param addToSendBuff Whether to add the message to the send buffer for retry.
|
|
291
290
|
* @returns The full transport ID of the message that was attempted to be sent.
|
|
292
291
|
*/
|
|
293
|
-
send(msg,
|
|
294
|
-
const fullMsg = this.constructMsg(msg);
|
|
292
|
+
send(msg, addToSendBuff = true) {
|
|
293
|
+
const fullMsg = this.constructMsg(msg, addToSendBuff);
|
|
295
294
|
log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
|
|
296
295
|
if (this.connection) {
|
|
297
296
|
const ok = this.connection.send(this.codec.toBuffer(fullMsg));
|
|
@@ -305,12 +304,6 @@ var Session = class {
|
|
|
305
304
|
`${this.from} -- failed to send ${fullMsg.id} to ${fullMsg.to}, connection not ready yet`
|
|
306
305
|
);
|
|
307
306
|
}
|
|
308
|
-
if (skipRetry)
|
|
309
|
-
return fullMsg.id;
|
|
310
|
-
this.addToSendBuff(fullMsg);
|
|
311
|
-
log?.info(
|
|
312
|
-
`${this.from} -- buffering msg ${fullMsg.id} until connection is healthy again`
|
|
313
|
-
);
|
|
314
307
|
return fullMsg.id;
|
|
315
308
|
}
|
|
316
309
|
sendHeartbeat() {
|
|
@@ -331,7 +324,7 @@ var Session = class {
|
|
|
331
324
|
type: "ACK"
|
|
332
325
|
}
|
|
333
326
|
},
|
|
334
|
-
|
|
327
|
+
false
|
|
335
328
|
);
|
|
336
329
|
this.heartbeatMisses++;
|
|
337
330
|
}
|
|
@@ -346,6 +339,9 @@ var Session = class {
|
|
|
346
339
|
log?.error(msg);
|
|
347
340
|
throw new Error(msg);
|
|
348
341
|
}
|
|
342
|
+
log?.info(
|
|
343
|
+
`${this.from} -- resending ${this.sendBuffer.length} buffered messages`
|
|
344
|
+
);
|
|
349
345
|
for (const msg of this.sendBuffer) {
|
|
350
346
|
log?.debug(`${this.from} -- resending ${JSON.stringify(msg)}`);
|
|
351
347
|
const ok = this.connection.send(this.codec.toBuffer(msg));
|
|
@@ -360,12 +356,6 @@ var Session = class {
|
|
|
360
356
|
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq > ack);
|
|
361
357
|
this.ack = seq + 1;
|
|
362
358
|
}
|
|
363
|
-
addToSendBuff(msg) {
|
|
364
|
-
this.sendBuffer.push(msg);
|
|
365
|
-
log?.debug(
|
|
366
|
-
`${this.from} -- send buff to ${this.to} now tracking ${this.sendBuffer.length} messages`
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
359
|
closeStaleConnection(conn) {
|
|
370
360
|
if (!this.connection || this.connection !== conn)
|
|
371
361
|
return;
|
|
@@ -408,7 +398,7 @@ var Session = class {
|
|
|
408
398
|
get nextExpectedSeq() {
|
|
409
399
|
return this.ack;
|
|
410
400
|
}
|
|
411
|
-
constructMsg(partialMsg) {
|
|
401
|
+
constructMsg(partialMsg, addToSendBuff = true) {
|
|
412
402
|
const msg = {
|
|
413
403
|
...partialMsg,
|
|
414
404
|
id: unsafeId(),
|
|
@@ -418,6 +408,9 @@ var Session = class {
|
|
|
418
408
|
ack: this.ack
|
|
419
409
|
};
|
|
420
410
|
this.seq++;
|
|
411
|
+
if (addToSendBuff) {
|
|
412
|
+
this.sendBuffer.push(msg);
|
|
413
|
+
}
|
|
421
414
|
return msg;
|
|
422
415
|
}
|
|
423
416
|
inspectSendBuffer() {
|
|
@@ -726,6 +719,8 @@ var ClientTransport = class extends Transport {
|
|
|
726
719
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
727
720
|
}
|
|
728
721
|
handleConnection(conn, to) {
|
|
722
|
+
if (this.state !== "open")
|
|
723
|
+
return;
|
|
729
724
|
let session = void 0;
|
|
730
725
|
const handshakeHandler = (data) => {
|
|
731
726
|
const handshake = this.receiveHandshakeResponseMessage(data);
|
|
@@ -844,6 +839,11 @@ var ServerTransport = class extends Transport {
|
|
|
844
839
|
);
|
|
845
840
|
}
|
|
846
841
|
handleConnection(conn) {
|
|
842
|
+
if (this.state !== "open")
|
|
843
|
+
return;
|
|
844
|
+
log?.info(
|
|
845
|
+
`${this.clientId} -- new incoming connection (id: ${conn.debugId})`
|
|
846
|
+
);
|
|
847
847
|
let session = void 0;
|
|
848
848
|
const client = () => session?.to ?? "unknown";
|
|
849
849
|
const handshakeHandler = (data) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as ClientTransport, C as Connection,
|
|
1
|
+
export { a as ClientTransport, C as Connection, l as EventHandler, E as EventMap, k as EventTypes, O as OpaqueTransportMessage, g as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, h as TransportMessage, f as TransportMessageSchema, c as TransportOptions, e as TransportStatus, j as isStreamClose, i as isStreamOpen } from '../index-2154021c.js';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as ClientTransport, C as Connection,
|
|
1
|
+
export { a as ClientTransport, C as Connection, l as EventHandler, E as EventMap, k as EventTypes, O as OpaqueTransportMessage, g as OpaqueTransportMessageSchema, S as ServerTransport, d as Session, T as Transport, b as TransportClientId, h as TransportMessage, f as TransportMessageSchema, c as TransportOptions, e as TransportStatus, j as isStreamClose, i as isStreamOpen } from '../index-2154021c.js';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
package/dist/transport/index.js
CHANGED
|
@@ -174,12 +174,11 @@ var Session = class {
|
|
|
174
174
|
* If the connection is not ready or the message fails to send, the message can be buffered for retry unless skipped.
|
|
175
175
|
*
|
|
176
176
|
* @param msg The partial message to be sent, which will be constructed into a full message.
|
|
177
|
-
* @param
|
|
178
|
-
* ack hearbeats, which contain information that can already be found in the other buffered messages.
|
|
177
|
+
* @param addToSendBuff Whether to add the message to the send buffer for retry.
|
|
179
178
|
* @returns The full transport ID of the message that was attempted to be sent.
|
|
180
179
|
*/
|
|
181
|
-
send(msg,
|
|
182
|
-
const fullMsg = this.constructMsg(msg);
|
|
180
|
+
send(msg, addToSendBuff = true) {
|
|
181
|
+
const fullMsg = this.constructMsg(msg, addToSendBuff);
|
|
183
182
|
log?.debug(`${this.from} -- sending ${JSON.stringify(fullMsg)}`);
|
|
184
183
|
if (this.connection) {
|
|
185
184
|
const ok = this.connection.send(this.codec.toBuffer(fullMsg));
|
|
@@ -193,12 +192,6 @@ var Session = class {
|
|
|
193
192
|
`${this.from} -- failed to send ${fullMsg.id} to ${fullMsg.to}, connection not ready yet`
|
|
194
193
|
);
|
|
195
194
|
}
|
|
196
|
-
if (skipRetry)
|
|
197
|
-
return fullMsg.id;
|
|
198
|
-
this.addToSendBuff(fullMsg);
|
|
199
|
-
log?.info(
|
|
200
|
-
`${this.from} -- buffering msg ${fullMsg.id} until connection is healthy again`
|
|
201
|
-
);
|
|
202
195
|
return fullMsg.id;
|
|
203
196
|
}
|
|
204
197
|
sendHeartbeat() {
|
|
@@ -219,7 +212,7 @@ var Session = class {
|
|
|
219
212
|
type: "ACK"
|
|
220
213
|
}
|
|
221
214
|
},
|
|
222
|
-
|
|
215
|
+
false
|
|
223
216
|
);
|
|
224
217
|
this.heartbeatMisses++;
|
|
225
218
|
}
|
|
@@ -234,6 +227,9 @@ var Session = class {
|
|
|
234
227
|
log?.error(msg);
|
|
235
228
|
throw new Error(msg);
|
|
236
229
|
}
|
|
230
|
+
log?.info(
|
|
231
|
+
`${this.from} -- resending ${this.sendBuffer.length} buffered messages`
|
|
232
|
+
);
|
|
237
233
|
for (const msg of this.sendBuffer) {
|
|
238
234
|
log?.debug(`${this.from} -- resending ${JSON.stringify(msg)}`);
|
|
239
235
|
const ok = this.connection.send(this.codec.toBuffer(msg));
|
|
@@ -248,12 +244,6 @@ var Session = class {
|
|
|
248
244
|
this.sendBuffer = this.sendBuffer.filter((unacked) => unacked.seq > ack);
|
|
249
245
|
this.ack = seq + 1;
|
|
250
246
|
}
|
|
251
|
-
addToSendBuff(msg) {
|
|
252
|
-
this.sendBuffer.push(msg);
|
|
253
|
-
log?.debug(
|
|
254
|
-
`${this.from} -- send buff to ${this.to} now tracking ${this.sendBuffer.length} messages`
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
247
|
closeStaleConnection(conn) {
|
|
258
248
|
if (!this.connection || this.connection !== conn)
|
|
259
249
|
return;
|
|
@@ -296,7 +286,7 @@ var Session = class {
|
|
|
296
286
|
get nextExpectedSeq() {
|
|
297
287
|
return this.ack;
|
|
298
288
|
}
|
|
299
|
-
constructMsg(partialMsg) {
|
|
289
|
+
constructMsg(partialMsg, addToSendBuff = true) {
|
|
300
290
|
const msg = {
|
|
301
291
|
...partialMsg,
|
|
302
292
|
id: unsafeId(),
|
|
@@ -306,6 +296,9 @@ var Session = class {
|
|
|
306
296
|
ack: this.ack
|
|
307
297
|
};
|
|
308
298
|
this.seq++;
|
|
299
|
+
if (addToSendBuff) {
|
|
300
|
+
this.sendBuffer.push(msg);
|
|
301
|
+
}
|
|
309
302
|
return msg;
|
|
310
303
|
}
|
|
311
304
|
inspectSendBuffer() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as it_pushable from 'it-pushable';
|
|
2
2
|
import WebSocket from 'isomorphic-ws';
|
|
3
3
|
import http from 'node:http';
|
|
4
|
-
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-
|
|
5
|
-
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-
|
|
4
|
+
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-2154021c.js';
|
|
5
|
+
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-533e1324.js';
|
|
6
6
|
import { Static } from '@sinclair/typebox';
|
|
7
7
|
import net from 'node:net';
|
|
8
8
|
import '../types-3e5768ec.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as it_pushable from 'it-pushable';
|
|
2
2
|
import WebSocket from 'isomorphic-ws';
|
|
3
3
|
import http from 'node:http';
|
|
4
|
-
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-
|
|
5
|
-
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-
|
|
4
|
+
import { P as PartialTransportMessage, T as Transport, C as Connection, O as OpaqueTransportMessage } from '../index-2154021c.js';
|
|
5
|
+
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-533e1324.js';
|
|
6
6
|
import { Static } from '@sinclair/typebox';
|
|
7
7
|
import net from 'node:net';
|
|
8
8
|
import '../types-3e5768ec.js';
|
package/dist/util/testHelpers.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UNCAUGHT_ERROR,
|
|
3
3
|
pushable
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-E2CP4UWB.js";
|
|
5
5
|
import "../chunk-5IZ2UHWV.js";
|
|
6
6
|
import {
|
|
7
7
|
Session,
|
|
8
8
|
defaultSessionOptions
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-WYHD3FN7.js";
|
|
10
10
|
import {
|
|
11
11
|
coerceErrorString
|
|
12
12
|
} from "../chunk-GFRAOY75.js";
|
package/package.json
CHANGED