@replit/river 0.23.8 → 0.23.10
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/{chunk-WQRQFAP6.js → chunk-B323CECK.js} +473 -15
- package/dist/chunk-B323CECK.js.map +1 -0
- package/dist/{chunk-ELZRZNA5.js → chunk-FRICSBDW.js} +2 -2
- package/dist/chunk-FRICSBDW.js.map +1 -0
- package/dist/{chunk-RJ6CXPBM.js → chunk-KBAZ5TWE.js} +129 -65
- package/dist/chunk-KBAZ5TWE.js.map +1 -0
- package/dist/{chunk-DXTG3E3B.js → chunk-UXQMGZKP.js} +2 -2
- package/dist/{chunk-CBNCT4B3.js → chunk-Z4G27Y2I.js} +2 -2
- package/dist/{connection-6ce35bd5.d.ts → connection-700340c4.d.ts} +1 -1
- package/dist/{connection-a3fdfa3a.d.ts → connection-efcd4e1a.d.ts} +1 -1
- package/dist/router/index.cjs +473 -14
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +41 -7
- package/dist/router/index.d.ts +41 -7
- package/dist/router/index.js +4 -2
- package/dist/{services-fd8a9894.d.ts → services-409c5545.d.ts} +10 -9
- package/dist/transport/impls/uds/client.cjs +122 -58
- package/dist/transport/impls/uds/client.cjs.map +1 -1
- 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 +3 -3
- package/dist/transport/impls/uds/server.cjs +103 -47
- package/dist/transport/impls/uds/server.cjs.map +1 -1
- 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 +3 -3
- package/dist/transport/impls/ws/client.cjs +125 -58
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- 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 +6 -3
- package/dist/transport/impls/ws/client.js.map +1 -1
- package/dist/transport/impls/ws/server.cjs +103 -47
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- 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 -3
- package/dist/transport/index.cjs +128 -64
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +1 -1
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +2 -2
- package/dist/{transport-3d34f714.d.ts → transport-cf856c41.d.ts} +46 -24
- package/dist/util/testHelpers.cjs +46 -4
- package/dist/util/testHelpers.cjs.map +1 -1
- package/dist/util/testHelpers.d.cts +2 -2
- package/dist/util/testHelpers.d.ts +2 -2
- package/dist/util/testHelpers.js +3 -3
- package/package.json +3 -3
- package/dist/chunk-ELZRZNA5.js.map +0 -1
- package/dist/chunk-RJ6CXPBM.js.map +0 -1
- package/dist/chunk-WQRQFAP6.js.map +0 -1
- /package/dist/{chunk-DXTG3E3B.js.map → chunk-UXQMGZKP.js.map} +0 -0
- /package/dist/{chunk-CBNCT4B3.js.map → chunk-Z4G27Y2I.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Codec } from './types-3e5768ec.js';
|
|
2
1
|
import { a as TelemetryInfo, M as MessageMetadata, T as TransportClientId, b as PropagationContext, L as Logger, P as PartialTransportMessage, c as TransportMessage, O as OpaqueTransportMessage, g as LogFn, h as LoggingLevel } from './index-60f03cb7.js';
|
|
2
|
+
import { C as Codec } from './types-3e5768ec.js';
|
|
3
3
|
import { TSchema, Static } from '@sinclair/typebox';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -77,7 +77,7 @@ interface SessionOptions {
|
|
|
77
77
|
declare class Session<ConnType extends Connection> {
|
|
78
78
|
private codec;
|
|
79
79
|
private options;
|
|
80
|
-
telemetry: TelemetryInfo;
|
|
80
|
+
readonly telemetry: TelemetryInfo;
|
|
81
81
|
/**
|
|
82
82
|
* The buffer of messages that have been sent but not yet acknowledged.
|
|
83
83
|
*/
|
|
@@ -86,12 +86,17 @@ declare class Session<ConnType extends Connection> {
|
|
|
86
86
|
* The active connection associated with this session
|
|
87
87
|
*/
|
|
88
88
|
connection?: ConnType;
|
|
89
|
+
/**
|
|
90
|
+
* A connection that is currently undergoing handshaking. Used to distinguish between the active
|
|
91
|
+
* connection, but still be able to close it if needed.
|
|
92
|
+
*/
|
|
93
|
+
private handshakingConnection?;
|
|
89
94
|
readonly from: TransportClientId;
|
|
90
95
|
readonly to: TransportClientId;
|
|
91
96
|
/**
|
|
92
97
|
* The unique ID of this session.
|
|
93
98
|
*/
|
|
94
|
-
id: string;
|
|
99
|
+
readonly id: string;
|
|
95
100
|
/**
|
|
96
101
|
* What the other side advertised as their session ID
|
|
97
102
|
* for this session.
|
|
@@ -135,10 +140,17 @@ declare class Session<ConnType extends Connection> {
|
|
|
135
140
|
resetBufferedMessages(): void;
|
|
136
141
|
sendBufferedMessages(conn: ConnType): void;
|
|
137
142
|
updateBookkeeping(ack: number, seq: number): void;
|
|
138
|
-
closeStaleConnection
|
|
143
|
+
private closeStaleConnection;
|
|
139
144
|
replaceWithNewConnection(newConn: ConnType): void;
|
|
145
|
+
replaceWithNewHandshakingConnection(newConn: ConnType): void;
|
|
140
146
|
beginGrace(cb: () => void): void;
|
|
141
|
-
cancelGrace(
|
|
147
|
+
cancelGrace({ keepHeartbeatMisses }?: {
|
|
148
|
+
keepHeartbeatMisses: boolean;
|
|
149
|
+
}): void;
|
|
150
|
+
/**
|
|
151
|
+
* Used to close the handshaking connection, if set.
|
|
152
|
+
*/
|
|
153
|
+
closeHandshakingConnection(expectedHandshakingConn?: ConnType): void;
|
|
142
154
|
close(): void;
|
|
143
155
|
get connected(): boolean;
|
|
144
156
|
get nextExpectedSeq(): number;
|
|
@@ -150,7 +162,6 @@ type ConnectionStatus = 'connect' | 'disconnect';
|
|
|
150
162
|
declare const ProtocolError: {
|
|
151
163
|
readonly RetriesExceeded: "conn_retry_exceeded";
|
|
152
164
|
readonly HandshakeFailed: "handshake_failed";
|
|
153
|
-
readonly UseAfterDestroy: "use_after_destroy";
|
|
154
165
|
readonly MessageOrderingViolated: "message_ordering_violated";
|
|
155
166
|
};
|
|
156
167
|
type ProtocolErrorType = (typeof ProtocolError)[keyof typeof ProtocolError];
|
|
@@ -168,11 +179,15 @@ interface EventMap {
|
|
|
168
179
|
type: ProtocolErrorType;
|
|
169
180
|
message: string;
|
|
170
181
|
};
|
|
182
|
+
transportStatus: {
|
|
183
|
+
status: TransportStatus;
|
|
184
|
+
};
|
|
171
185
|
}
|
|
172
186
|
type EventTypes = keyof EventMap;
|
|
173
187
|
type EventHandler<K extends EventTypes> = (event: EventMap[K]) => unknown;
|
|
174
188
|
declare class EventDispatcher<T extends EventTypes> {
|
|
175
189
|
private eventListeners;
|
|
190
|
+
removeAllListeners(): void;
|
|
176
191
|
numberOfListeners<K extends T>(eventType: K): number;
|
|
177
192
|
addEventListener<K extends T>(eventType: K, handler: EventHandler<K>): void;
|
|
178
193
|
removeEventListener<K extends T>(eventType: K, handler: EventHandler<K>): void;
|
|
@@ -278,7 +293,7 @@ type ServiceContextWithState<State> = ServiceContext & {
|
|
|
278
293
|
state: State;
|
|
279
294
|
};
|
|
280
295
|
type ServiceContextWithTransportInfo<State> = ServiceContext & {
|
|
281
|
-
state:
|
|
296
|
+
state: State;
|
|
282
297
|
to: TransportClientId;
|
|
283
298
|
from: TransportClientId;
|
|
284
299
|
streamId: string;
|
|
@@ -324,10 +339,9 @@ declare function createServerHandshakeOptions<MetadataSchema extends TSchema = T
|
|
|
324
339
|
/**
|
|
325
340
|
* Represents the possible states of a transport.
|
|
326
341
|
* @property {'open'} open - The transport is open and operational (note that this doesn't mean it is actively connected)
|
|
327
|
-
* @property {'closed'} closed - The transport is closed and
|
|
328
|
-
* @property {'destroyed'} destroyed - The transport is permanently destroyed and cannot be reopened.
|
|
342
|
+
* @property {'closed'} closed - The transport is permanently closed and cannot be reopened.
|
|
329
343
|
*/
|
|
330
|
-
type TransportStatus = 'open' | 'closed'
|
|
344
|
+
type TransportStatus = 'open' | 'closed';
|
|
331
345
|
type TransportOptions = SessionOptions;
|
|
332
346
|
type ProvidedTransportOptions = Partial<TransportOptions>;
|
|
333
347
|
type ClientTransportOptions = TransportOptions & ConnectionRetryOptions;
|
|
@@ -366,10 +380,9 @@ type ProvidedServerTransportOptions = Partial<ServerTransportOptions>;
|
|
|
366
380
|
*/
|
|
367
381
|
declare abstract class Transport<ConnType extends Connection> {
|
|
368
382
|
/**
|
|
369
|
-
*
|
|
370
|
-
* A destroyed transport will not attempt to reconnect and cannot be used again.
|
|
383
|
+
* The status of the transport.
|
|
371
384
|
*/
|
|
372
|
-
|
|
385
|
+
private status;
|
|
373
386
|
/**
|
|
374
387
|
* The {@link Codec} used to encode and decode messages.
|
|
375
388
|
*/
|
|
@@ -419,11 +432,21 @@ declare abstract class Transport<ConnType extends Connection> {
|
|
|
419
432
|
*/
|
|
420
433
|
protected onConnect(conn: ConnType, connectedTo: TransportClientId, session: Session<ConnType>, isReconnect: boolean): void;
|
|
421
434
|
protected createSession(to: TransportClientId, conn?: ConnType, propagationCtx?: PropagationContext): Session<ConnType>;
|
|
422
|
-
protected getOrCreateSession(to
|
|
435
|
+
protected getOrCreateSession({ to, conn, handshakingConn, sessionId, propagationCtx, }: {
|
|
436
|
+
to: TransportClientId;
|
|
437
|
+
conn?: ConnType;
|
|
438
|
+
handshakingConn?: ConnType;
|
|
439
|
+
sessionId?: string;
|
|
440
|
+
propagationCtx?: PropagationContext;
|
|
441
|
+
}): {
|
|
423
442
|
session: Session<ConnType>;
|
|
424
443
|
isReconnect: boolean;
|
|
425
444
|
};
|
|
426
|
-
protected deleteSession(session
|
|
445
|
+
protected deleteSession({ session, closeHandshakingConnection, handshakingConn, }: {
|
|
446
|
+
session: Session<ConnType>;
|
|
447
|
+
closeHandshakingConnection: boolean;
|
|
448
|
+
handshakingConn?: ConnType;
|
|
449
|
+
}): void;
|
|
427
450
|
/**
|
|
428
451
|
* The downstream implementation needs to call this when a connection is closed.
|
|
429
452
|
* @param conn The connection object.
|
|
@@ -460,8 +483,8 @@ declare abstract class Transport<ConnType extends Connection> {
|
|
|
460
483
|
* @param msg The message to send.
|
|
461
484
|
* @returns The ID of the sent message or undefined if it wasn't sent
|
|
462
485
|
*/
|
|
463
|
-
send(to: TransportClientId, msg: PartialTransportMessage): string
|
|
464
|
-
sendCloseStream(to: TransportClientId, streamId: string): string
|
|
486
|
+
send(to: TransportClientId, msg: PartialTransportMessage): string;
|
|
487
|
+
sendCloseStream(to: TransportClientId, streamId: string): string;
|
|
465
488
|
protected protocolError(type: ProtocolErrorType, message: string): void;
|
|
466
489
|
/**
|
|
467
490
|
* Default close implementation for transports. You should override this in the downstream
|
|
@@ -469,12 +492,7 @@ declare abstract class Transport<ConnType extends Connection> {
|
|
|
469
492
|
* Closes the transport. Any messages sent while the transport is closed will be silently discarded.
|
|
470
493
|
*/
|
|
471
494
|
close(): void;
|
|
472
|
-
|
|
473
|
-
* Default destroy implementation for transports. You should override this in the downstream
|
|
474
|
-
* implementation if you need to do any additional cleanup and call super.destroy() at the end.
|
|
475
|
-
* Destroys the transport. Any messages sent while the transport is destroyed will throw an error.
|
|
476
|
-
*/
|
|
477
|
-
destroy(): void;
|
|
495
|
+
getStatus(): TransportStatus;
|
|
478
496
|
}
|
|
479
497
|
declare abstract class ClientTransport<ConnType extends Connection> extends Transport<ConnType> {
|
|
480
498
|
/**
|
|
@@ -515,7 +533,11 @@ declare abstract class ClientTransport<ConnType extends Connection> extends Tran
|
|
|
515
533
|
* @param to The client ID of the node to connect to.
|
|
516
534
|
*/
|
|
517
535
|
connect(to: TransportClientId): Promise<void>;
|
|
518
|
-
protected deleteSession(session
|
|
536
|
+
protected deleteSession({ session, closeHandshakingConnection, handshakingConn, }: {
|
|
537
|
+
session: Session<ConnType>;
|
|
538
|
+
closeHandshakingConnection: boolean;
|
|
539
|
+
handshakingConn?: ConnType;
|
|
540
|
+
}): void;
|
|
519
541
|
protected sendHandshake(to: TransportClientId, conn: ConnType): Promise<boolean>;
|
|
520
542
|
close(): void;
|
|
521
543
|
}
|
|
@@ -353,7 +353,7 @@ function Err(error) {
|
|
|
353
353
|
var import_api = require("@opentelemetry/api");
|
|
354
354
|
|
|
355
355
|
// package.json
|
|
356
|
-
var version = "0.23.
|
|
356
|
+
var version = "0.23.10";
|
|
357
357
|
|
|
358
358
|
// tracing/index.ts
|
|
359
359
|
function createSessionTelemetryInfo(session, propagationCtx) {
|
|
@@ -403,6 +403,11 @@ var Session = class {
|
|
|
403
403
|
* The active connection associated with this session
|
|
404
404
|
*/
|
|
405
405
|
connection;
|
|
406
|
+
/**
|
|
407
|
+
* A connection that is currently undergoing handshaking. Used to distinguish between the active
|
|
408
|
+
* connection, but still be able to close it if needed.
|
|
409
|
+
*/
|
|
410
|
+
handshakingConnection;
|
|
406
411
|
from;
|
|
407
412
|
to;
|
|
408
413
|
/**
|
|
@@ -582,23 +587,60 @@ var Session = class {
|
|
|
582
587
|
this.cancelGrace();
|
|
583
588
|
this.sendBufferedMessages(newConn);
|
|
584
589
|
this.connection = newConn;
|
|
590
|
+
this.handshakingConnection = void 0;
|
|
591
|
+
}
|
|
592
|
+
replaceWithNewHandshakingConnection(newConn) {
|
|
593
|
+
this.handshakingConnection = newConn;
|
|
585
594
|
}
|
|
586
595
|
beginGrace(cb) {
|
|
587
596
|
this.log?.info(
|
|
588
597
|
`starting ${this.options.sessionDisconnectGraceMs}ms grace period until session to ${this.to} is closed`,
|
|
589
598
|
this.loggingMetadata
|
|
590
599
|
);
|
|
600
|
+
this.cancelGrace({ keepHeartbeatMisses: true });
|
|
591
601
|
this.disconnectionGrace = setTimeout(() => {
|
|
592
|
-
this.
|
|
602
|
+
if (this.connection !== void 0) {
|
|
603
|
+
this.log?.warn(
|
|
604
|
+
`grace period for ${this.to} elapsed while connected. not calling callback`,
|
|
605
|
+
{
|
|
606
|
+
...this.loggingMetadata,
|
|
607
|
+
connId: this.connection.id,
|
|
608
|
+
tags: ["invariant-violation"]
|
|
609
|
+
}
|
|
610
|
+
);
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
this.log?.info(
|
|
614
|
+
`grace period for ${this.to} elapsed`,
|
|
615
|
+
this.loggingMetadata
|
|
616
|
+
);
|
|
593
617
|
cb();
|
|
594
618
|
}, this.options.sessionDisconnectGraceMs);
|
|
595
619
|
}
|
|
596
620
|
// called on reconnect of the underlying session
|
|
597
|
-
cancelGrace(
|
|
598
|
-
|
|
621
|
+
cancelGrace({ keepHeartbeatMisses } = {
|
|
622
|
+
keepHeartbeatMisses: false
|
|
623
|
+
}) {
|
|
624
|
+
if (!keepHeartbeatMisses) {
|
|
625
|
+
this.heartbeatMisses = 0;
|
|
626
|
+
}
|
|
627
|
+
if (this.disconnectionGrace === void 0)
|
|
628
|
+
return;
|
|
599
629
|
clearTimeout(this.disconnectionGrace);
|
|
600
630
|
this.disconnectionGrace = void 0;
|
|
601
631
|
}
|
|
632
|
+
/**
|
|
633
|
+
* Used to close the handshaking connection, if set.
|
|
634
|
+
*/
|
|
635
|
+
closeHandshakingConnection(expectedHandshakingConn) {
|
|
636
|
+
if (this.handshakingConnection === void 0)
|
|
637
|
+
return;
|
|
638
|
+
if (expectedHandshakingConn !== void 0 && this.handshakingConnection === expectedHandshakingConn) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
this.handshakingConnection.close();
|
|
642
|
+
this.handshakingConnection = void 0;
|
|
643
|
+
}
|
|
602
644
|
// closed when we want to discard the whole session
|
|
603
645
|
// (i.e. shutdown or session disconnect)
|
|
604
646
|
close() {
|