@replit/river 0.207.3 → 0.208.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/dist/{adapter-f2b6e211.d.ts → adapter-ChksXKVN.d.ts} +2 -2
- package/dist/adapter-Cuc4JtfV.d.cts +46 -0
- package/dist/{chunk-BO7MFCO6.js → chunk-2JNVDUMN.js} +55 -97
- package/dist/chunk-2JNVDUMN.js.map +1 -0
- package/dist/{chunk-B7REV3ZV.js → chunk-DKW3GC3M.js} +2 -2
- package/dist/{chunk-QGPYCXV4.js → chunk-ETZAHFGQ.js} +80 -61
- package/dist/chunk-ETZAHFGQ.js.map +1 -0
- package/dist/codec/index.d.cts +3 -3
- package/dist/codec/index.d.ts +3 -3
- package/dist/codec/index.js +2 -2
- package/dist/connection-BF4zg6Qv.d.cts +35 -0
- package/dist/{connection-06d72f2e.d.ts → connection-Donr3JRB.d.ts} +4 -4
- package/dist/index-C9tpZjBN.d.cts +37 -0
- package/dist/{index-02554794.d.ts → index-D8IOd3LG.d.ts} +2 -2
- package/dist/logging/index.d.cts +2 -2
- package/dist/logging/index.d.ts +2 -2
- package/dist/{message-01c3e85a.d.ts → message-Di94OL80.d.cts} +1 -1
- package/dist/message-Di94OL80.d.ts +108 -0
- package/dist/router/index.cjs +62 -43
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +27 -8
- package/dist/router/index.d.ts +27 -8
- package/dist/router/index.js +1 -1
- package/dist/testUtil/index.cjs +56 -105
- package/dist/testUtil/index.cjs.map +1 -1
- package/dist/testUtil/index.d.cts +5 -5
- package/dist/testUtil/index.d.ts +5 -5
- package/dist/testUtil/index.js +7 -14
- package/dist/testUtil/index.js.map +1 -1
- package/dist/transport/impls/ws/client.cjs +51 -80
- package/dist/transport/impls/ws/client.cjs.map +1 -1
- package/dist/transport/impls/ws/client.d.cts +6 -6
- package/dist/transport/impls/ws/client.d.ts +6 -6
- package/dist/transport/impls/ws/client.js +3 -3
- package/dist/transport/impls/ws/server.cjs +52 -85
- package/dist/transport/impls/ws/server.cjs.map +1 -1
- package/dist/transport/impls/ws/server.d.cts +6 -6
- package/dist/transport/impls/ws/server.d.ts +6 -6
- package/dist/transport/impls/ws/server.js +3 -3
- package/dist/transport/index.cjs +52 -94
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.cts +6 -6
- package/dist/transport/index.d.ts +6 -6
- package/dist/transport/index.js +3 -3
- package/dist/transport-CCaWx1Rb.d.cts +1566 -0
- package/dist/{services-87887bc5.d.ts → transport-CZb3vdB4.d.ts} +344 -347
- package/dist/{wslike-e0b32dd5.d.ts → wslike-Dng9H1C7.d.cts} +1 -1
- package/dist/wslike-Dng9H1C7.d.ts +40 -0
- package/package.json +3 -3
- package/dist/chunk-BO7MFCO6.js.map +0 -1
- package/dist/chunk-QGPYCXV4.js.map +0 -1
- /package/dist/{chunk-B7REV3ZV.js.map → chunk-DKW3GC3M.js.map} +0 -0
package/dist/router/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { A as AnyServiceSchemaMap,
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
1
|
+
import { A as AnyServiceSchemaMap, b as Connection, S as ServerHandshakeOptions, c as ServiceContext, d as ProcedureHandlerContext, e as PayloadType, I as InstantiatedServiceSchemaMap, f as ParsedMetadata, g as AnyProcedure } from '../transport-CCaWx1Rb.cjs';
|
|
2
|
+
export { N as BaseErrorSchemaType, L as CANCEL_CODE, Q as Client, X as Err, Z as ErrResult, K as INVALID_REQUEST_CODE, T as Ok, _ as OkResult, n as ProcErrors, j as ProcHandler, k as ProcInit, l as ProcRequest, m as ProcResponse, o as ProcType, E as Procedure, F as ProcedureErrorSchemaType, y as ProcedureMap, R as RPCProcedure, D as Readable, M as ReaderErrorSchema, a1 as ResponseData, Y as Result, a0 as ResultUnwrapErr, $ as ResultUnwrapOk, t as SerializedProcedureSchema, x as SerializedProcedureSchemaProtocolv1, q as SerializedServerSchema, v as SerializedServerSchemaProtocolv1, r as SerializedServiceSchema, w as SerializedServiceSchemaProtocolv1, h as Service, i as ServiceConfiguration, p as ServiceSchema, B as StreamProcedure, z as SubscriptionProcedure, H as UNCAUGHT_ERROR_CODE, J as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, O as createClient, a2 as createClientHandshakeOptions, a3 as createServerHandshakeOptions, G as flattenErrorType, s as serializeSchema, u as serializeSchemaV1Compat } from '../transport-CCaWx1Rb.cjs';
|
|
3
|
+
import { Static } from '@sinclair/typebox';
|
|
4
|
+
import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-Di94OL80.cjs';
|
|
4
5
|
import { ServerTransport } from '../transport/index.cjs';
|
|
5
|
-
import '@sinclair/typebox';
|
|
6
6
|
import '@opentelemetry/api';
|
|
7
|
-
import '../index-
|
|
8
|
-
import '../adapter-
|
|
7
|
+
import '../index-C9tpZjBN.cjs';
|
|
8
|
+
import '../adapter-Cuc4JtfV.cjs';
|
|
9
9
|
|
|
10
10
|
type StreamId = string;
|
|
11
11
|
/**
|
|
@@ -33,6 +33,21 @@ interface ProcStream {
|
|
|
33
33
|
handleMsg: (msg: OpaqueTransportMessage) => void;
|
|
34
34
|
handleSessionDisconnect: () => void;
|
|
35
35
|
}
|
|
36
|
+
interface MiddlewareContext extends Readonly<Omit<ProcedureHandlerContext<unknown>, 'cancel'>> {
|
|
37
|
+
readonly streamId: StreamId;
|
|
38
|
+
readonly procedureName: string;
|
|
39
|
+
readonly serviceName: string;
|
|
40
|
+
}
|
|
41
|
+
interface MiddlewareParam {
|
|
42
|
+
readonly ctx: MiddlewareContext;
|
|
43
|
+
readonly reqInit: Static<PayloadType>;
|
|
44
|
+
next: () => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Middleware is a function that can inspect requests as they are received.
|
|
48
|
+
* For now modification of the request is not supported behavior.
|
|
49
|
+
*/
|
|
50
|
+
type Middleware = (param: MiddlewareParam) => void;
|
|
36
51
|
/**
|
|
37
52
|
* Creates a server instance that listens for incoming messages from a transport and routes them to the appropriate service and procedure.
|
|
38
53
|
* The server tracks the state of each service along with open streams and the extended context object.
|
|
@@ -50,8 +65,12 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
|
|
|
50
65
|
* cascading stream errors.
|
|
51
66
|
*/
|
|
52
67
|
maxCancelledStreamTombstonesPerSession?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Middlewares run before procedure handlers allowing you to inspect requests and responses..
|
|
70
|
+
*/
|
|
71
|
+
middlewares?: Array<Middleware>;
|
|
53
72
|
}>): Server<Services>;
|
|
54
73
|
|
|
55
|
-
var version = "0.
|
|
74
|
+
var version = "0.208.0";
|
|
56
75
|
|
|
57
|
-
export { ParsedMetadata, version as RIVER_VERSION, Server, ServiceContext, createServer };
|
|
76
|
+
export { type Middleware, type MiddlewareContext, type MiddlewareParam, ParsedMetadata, PayloadType, ProcedureHandlerContext, version as RIVER_VERSION, type Server, ServiceContext, createServer };
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { A as AnyServiceSchemaMap,
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
1
|
+
import { A as AnyServiceSchemaMap, b as Connection, S as ServerHandshakeOptions, c as ServiceContext, d as ProcedureHandlerContext, e as PayloadType, I as InstantiatedServiceSchemaMap, f as ParsedMetadata, g as AnyProcedure } from '../transport-CZb3vdB4.js';
|
|
2
|
+
export { N as BaseErrorSchemaType, L as CANCEL_CODE, Q as Client, X as Err, Z as ErrResult, K as INVALID_REQUEST_CODE, T as Ok, _ as OkResult, n as ProcErrors, j as ProcHandler, k as ProcInit, l as ProcRequest, m as ProcResponse, o as ProcType, E as Procedure, F as ProcedureErrorSchemaType, y as ProcedureMap, R as RPCProcedure, D as Readable, M as ReaderErrorSchema, a1 as ResponseData, Y as Result, a0 as ResultUnwrapErr, $ as ResultUnwrapOk, t as SerializedProcedureSchema, x as SerializedProcedureSchemaProtocolv1, q as SerializedServerSchema, v as SerializedServerSchemaProtocolv1, r as SerializedServiceSchema, w as SerializedServiceSchemaProtocolv1, h as Service, i as ServiceConfiguration, p as ServiceSchema, B as StreamProcedure, z as SubscriptionProcedure, H as UNCAUGHT_ERROR_CODE, J as UNEXPECTED_DISCONNECT_CODE, U as UploadProcedure, V as ValidProcType, W as Writable, O as createClient, a2 as createClientHandshakeOptions, a3 as createServerHandshakeOptions, G as flattenErrorType, s as serializeSchema, u as serializeSchemaV1Compat } from '../transport-CZb3vdB4.js';
|
|
3
|
+
import { Static } from '@sinclair/typebox';
|
|
4
|
+
import { T as TransportClientId, O as OpaqueTransportMessage } from '../message-Di94OL80.js';
|
|
4
5
|
import { ServerTransport } from '../transport/index.js';
|
|
5
|
-
import '@sinclair/typebox';
|
|
6
6
|
import '@opentelemetry/api';
|
|
7
|
-
import '../index-
|
|
8
|
-
import '../adapter-
|
|
7
|
+
import '../index-D8IOd3LG.js';
|
|
8
|
+
import '../adapter-ChksXKVN.js';
|
|
9
9
|
|
|
10
10
|
type StreamId = string;
|
|
11
11
|
/**
|
|
@@ -33,6 +33,21 @@ interface ProcStream {
|
|
|
33
33
|
handleMsg: (msg: OpaqueTransportMessage) => void;
|
|
34
34
|
handleSessionDisconnect: () => void;
|
|
35
35
|
}
|
|
36
|
+
interface MiddlewareContext extends Readonly<Omit<ProcedureHandlerContext<unknown>, 'cancel'>> {
|
|
37
|
+
readonly streamId: StreamId;
|
|
38
|
+
readonly procedureName: string;
|
|
39
|
+
readonly serviceName: string;
|
|
40
|
+
}
|
|
41
|
+
interface MiddlewareParam {
|
|
42
|
+
readonly ctx: MiddlewareContext;
|
|
43
|
+
readonly reqInit: Static<PayloadType>;
|
|
44
|
+
next: () => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Middleware is a function that can inspect requests as they are received.
|
|
48
|
+
* For now modification of the request is not supported behavior.
|
|
49
|
+
*/
|
|
50
|
+
type Middleware = (param: MiddlewareParam) => void;
|
|
36
51
|
/**
|
|
37
52
|
* Creates a server instance that listens for incoming messages from a transport and routes them to the appropriate service and procedure.
|
|
38
53
|
* The server tracks the state of each service along with open streams and the extended context object.
|
|
@@ -50,8 +65,12 @@ declare function createServer<Services extends AnyServiceSchemaMap>(transport: S
|
|
|
50
65
|
* cascading stream errors.
|
|
51
66
|
*/
|
|
52
67
|
maxCancelledStreamTombstonesPerSession?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Middlewares run before procedure handlers allowing you to inspect requests and responses..
|
|
70
|
+
*/
|
|
71
|
+
middlewares?: Array<Middleware>;
|
|
53
72
|
}>): Server<Services>;
|
|
54
73
|
|
|
55
|
-
var version = "0.
|
|
74
|
+
var version = "0.208.0";
|
|
56
75
|
|
|
57
|
-
export { ParsedMetadata, version as RIVER_VERSION, Server, ServiceContext, createServer };
|
|
76
|
+
export { type Middleware, type MiddlewareContext, type MiddlewareParam, ParsedMetadata, PayloadType, ProcedureHandlerContext, version as RIVER_VERSION, type Server, ServiceContext, createServer };
|
package/dist/router/index.js
CHANGED
package/dist/testUtil/index.cjs
CHANGED
|
@@ -488,13 +488,11 @@ var SessionConnecting = class extends IdentifiedSessionWithGracePeriod {
|
|
|
488
488
|
this.listeners = props.listeners;
|
|
489
489
|
this.connPromise.then(
|
|
490
490
|
(conn) => {
|
|
491
|
-
if (this._isConsumed)
|
|
492
|
-
return;
|
|
491
|
+
if (this._isConsumed) return;
|
|
493
492
|
this.listeners.onConnectionEstablished(conn);
|
|
494
493
|
},
|
|
495
494
|
(err) => {
|
|
496
|
-
if (this._isConsumed)
|
|
497
|
-
return;
|
|
495
|
+
if (this._isConsumed) return;
|
|
498
496
|
this.listeners.onConnectionFailed(err);
|
|
499
497
|
}
|
|
500
498
|
);
|
|
@@ -555,7 +553,7 @@ function coerceErrorString(err) {
|
|
|
555
553
|
}
|
|
556
554
|
|
|
557
555
|
// package.json
|
|
558
|
-
var version = "0.
|
|
556
|
+
var version = "0.208.0";
|
|
559
557
|
|
|
560
558
|
// tracing/index.ts
|
|
561
559
|
function getPropagationContext(ctx) {
|
|
@@ -569,7 +567,7 @@ function getPropagationContext(ctx) {
|
|
|
569
567
|
function createSessionTelemetryInfo(tracer, sessionId, to, from, propagationCtx) {
|
|
570
568
|
const parentCtx = propagationCtx ? import_api.propagation.extract(import_api.context.active(), propagationCtx) : import_api.context.active();
|
|
571
569
|
const span = tracer.startSpan(
|
|
572
|
-
`river.session
|
|
570
|
+
`river.session`,
|
|
573
571
|
{
|
|
574
572
|
attributes: {
|
|
575
573
|
component: "river",
|
|
@@ -585,7 +583,7 @@ function createSessionTelemetryInfo(tracer, sessionId, to, from, propagationCtx)
|
|
|
585
583
|
}
|
|
586
584
|
function createConnectionTelemetryInfo(tracer, connection, info) {
|
|
587
585
|
const span = tracer.startSpan(
|
|
588
|
-
`connection
|
|
586
|
+
`river.connection`,
|
|
589
587
|
{
|
|
590
588
|
attributes: {
|
|
591
589
|
component: "river",
|
|
@@ -615,9 +613,9 @@ var SessionWaitingForHandshake = class extends CommonSession {
|
|
|
615
613
|
this.handshakeTimeout = setTimeout(() => {
|
|
616
614
|
this.listeners.onHandshakeTimeout();
|
|
617
615
|
}, this.options.handshakeTimeoutMs);
|
|
618
|
-
this.conn.
|
|
619
|
-
this.conn.
|
|
620
|
-
this.conn.
|
|
616
|
+
this.conn.setDataListener(this.onHandshakeData);
|
|
617
|
+
this.conn.setErrorListener(this.listeners.onConnectionErrored);
|
|
618
|
+
this.conn.setCloseListener(this.listeners.onConnectionClosed);
|
|
621
619
|
}
|
|
622
620
|
get loggingMetadata() {
|
|
623
621
|
return {
|
|
@@ -641,9 +639,9 @@ var SessionWaitingForHandshake = class extends CommonSession {
|
|
|
641
639
|
return sendMessage(this.conn, this.codec, msg);
|
|
642
640
|
}
|
|
643
641
|
_handleStateExit() {
|
|
644
|
-
this.conn.removeDataListener(
|
|
645
|
-
this.conn.removeErrorListener(
|
|
646
|
-
this.conn.removeCloseListener(
|
|
642
|
+
this.conn.removeDataListener();
|
|
643
|
+
this.conn.removeErrorListener();
|
|
644
|
+
this.conn.removeCloseListener();
|
|
647
645
|
clearTimeout(this.handshakeTimeout);
|
|
648
646
|
this.handshakeTimeout = void 0;
|
|
649
647
|
}
|
|
@@ -665,9 +663,9 @@ var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
|
|
|
665
663
|
this.handshakeTimeout = setTimeout(() => {
|
|
666
664
|
this.listeners.onHandshakeTimeout();
|
|
667
665
|
}, this.options.handshakeTimeoutMs);
|
|
668
|
-
this.conn.
|
|
669
|
-
this.conn.
|
|
670
|
-
this.conn.
|
|
666
|
+
this.conn.setDataListener(this.onHandshakeData);
|
|
667
|
+
this.conn.setErrorListener(this.listeners.onConnectionErrored);
|
|
668
|
+
this.conn.setCloseListener(this.listeners.onConnectionClosed);
|
|
671
669
|
}
|
|
672
670
|
get loggingMetadata() {
|
|
673
671
|
return {
|
|
@@ -691,9 +689,9 @@ var SessionHandshaking = class extends IdentifiedSessionWithGracePeriod {
|
|
|
691
689
|
}
|
|
692
690
|
_handleStateExit() {
|
|
693
691
|
super._handleStateExit();
|
|
694
|
-
this.conn.removeDataListener(
|
|
695
|
-
this.conn.removeErrorListener(
|
|
696
|
-
this.conn.removeCloseListener(
|
|
692
|
+
this.conn.removeDataListener();
|
|
693
|
+
this.conn.removeErrorListener();
|
|
694
|
+
this.conn.removeCloseListener();
|
|
697
695
|
if (this.handshakeTimeout) {
|
|
698
696
|
clearTimeout(this.handshakeTimeout);
|
|
699
697
|
this.handshakeTimeout = void 0;
|
|
@@ -749,9 +747,9 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
749
747
|
super(props);
|
|
750
748
|
this.conn = props.conn;
|
|
751
749
|
this.listeners = props.listeners;
|
|
752
|
-
this.conn.
|
|
753
|
-
this.conn.
|
|
754
|
-
this.conn.
|
|
750
|
+
this.conn.setDataListener(this.onMessageData);
|
|
751
|
+
this.conn.setCloseListener(this.listeners.onConnectionClosed);
|
|
752
|
+
this.conn.setErrorListener(this.listeners.onConnectionErrored);
|
|
755
753
|
}
|
|
756
754
|
sendBufferedMessages() {
|
|
757
755
|
if (this.sendBuffer.length > 0) {
|
|
@@ -860,9 +858,9 @@ var SessionConnected = class extends IdentifiedSession {
|
|
|
860
858
|
};
|
|
861
859
|
_handleStateExit() {
|
|
862
860
|
super._handleStateExit();
|
|
863
|
-
this.conn.removeDataListener(
|
|
864
|
-
this.conn.removeCloseListener(
|
|
865
|
-
this.conn.removeErrorListener(
|
|
861
|
+
this.conn.removeDataListener();
|
|
862
|
+
this.conn.removeCloseListener();
|
|
863
|
+
this.conn.removeErrorListener();
|
|
866
864
|
if (this.heartbeatHandle) {
|
|
867
865
|
clearInterval(this.heartbeatHandle);
|
|
868
866
|
this.heartbeatHandle = void 0;
|
|
@@ -1054,8 +1052,7 @@ var Transport = class {
|
|
|
1054
1052
|
* @param message The received message.
|
|
1055
1053
|
*/
|
|
1056
1054
|
handleMsg(message) {
|
|
1057
|
-
if (this.getStatus() !== "open")
|
|
1058
|
-
return;
|
|
1055
|
+
if (this.getStatus() !== "open") return;
|
|
1059
1056
|
this.eventDispatcher.dispatchEvent("message", message);
|
|
1060
1057
|
}
|
|
1061
1058
|
/**
|
|
@@ -1143,8 +1140,7 @@ var Transport = class {
|
|
|
1143
1140
|
});
|
|
1144
1141
|
}
|
|
1145
1142
|
deleteSession(session, options) {
|
|
1146
|
-
if (session._isConsumed)
|
|
1147
|
-
return;
|
|
1143
|
+
if (session._isConsumed) return;
|
|
1148
1144
|
const loggingMetadata = session.loggingMetadata;
|
|
1149
1145
|
if (loggingMetadata.tags && options?.unhealthy) {
|
|
1150
1146
|
loggingMetadata.tags.push("unhealthy-session");
|
|
@@ -1164,7 +1160,7 @@ var Transport = class {
|
|
|
1164
1160
|
}
|
|
1165
1161
|
// common listeners
|
|
1166
1162
|
onSessionGracePeriodElapsed(session) {
|
|
1167
|
-
this.log?.
|
|
1163
|
+
this.log?.info(
|
|
1168
1164
|
`session to ${session.to} grace period elapsed, closing`,
|
|
1169
1165
|
session.loggingMetadata
|
|
1170
1166
|
);
|
|
@@ -1521,15 +1517,6 @@ var ClientTransport = class extends Transport {
|
|
|
1521
1517
|
});
|
|
1522
1518
|
const res = connectedSession.sendBufferedMessages();
|
|
1523
1519
|
if (!res.ok) {
|
|
1524
|
-
this.log?.error(`failed to send buffered messages: ${res.reason}`, {
|
|
1525
|
-
...connectedSession.loggingMetadata,
|
|
1526
|
-
transportMessage: msg
|
|
1527
|
-
});
|
|
1528
|
-
this.protocolError({
|
|
1529
|
-
type: ProtocolError.MessageSendFailure,
|
|
1530
|
-
message: res.reason
|
|
1531
|
-
});
|
|
1532
|
-
this.deleteSession(connectedSession, { unhealthy: true });
|
|
1533
1520
|
return;
|
|
1534
1521
|
}
|
|
1535
1522
|
this.updateSession(connectedSession);
|
|
@@ -1731,8 +1718,7 @@ var ServerTransport = class extends Transport {
|
|
|
1731
1718
|
super.deleteSession(session, options);
|
|
1732
1719
|
}
|
|
1733
1720
|
handleConnection(conn) {
|
|
1734
|
-
if (this.getStatus() !== "open")
|
|
1735
|
-
return;
|
|
1721
|
+
if (this.getStatus() !== "open") return;
|
|
1736
1722
|
this.log?.info(`new incoming connection`, {
|
|
1737
1723
|
...conn.loggingMetadata,
|
|
1738
1724
|
clientId: this.clientId
|
|
@@ -2076,18 +2062,6 @@ var ServerTransport = class extends Transport {
|
|
|
2076
2062
|
);
|
|
2077
2063
|
const bufferSendRes = connectedSession.sendBufferedMessages();
|
|
2078
2064
|
if (!bufferSendRes.ok) {
|
|
2079
|
-
this.log?.error(
|
|
2080
|
-
`failed to send buffered messages: ${bufferSendRes.reason}`,
|
|
2081
|
-
{
|
|
2082
|
-
...connectedSession.loggingMetadata,
|
|
2083
|
-
transportMessage: msg
|
|
2084
|
-
}
|
|
2085
|
-
);
|
|
2086
|
-
this.protocolError({
|
|
2087
|
-
type: ProtocolError.MessageSendFailure,
|
|
2088
|
-
message: bufferSendRes.reason
|
|
2089
|
-
});
|
|
2090
|
-
this.deleteSession(connectedSession, { unhealthy: true });
|
|
2091
2065
|
return;
|
|
2092
2066
|
}
|
|
2093
2067
|
this.sessionHandshakeMetadata.set(connectedSession.to, parsedMetadata);
|
|
@@ -2118,60 +2092,44 @@ var Connection = class {
|
|
|
2118
2092
|
}
|
|
2119
2093
|
return metadata;
|
|
2120
2094
|
}
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
_errorListeners = /* @__PURE__ */ new Set();
|
|
2125
|
-
get dataListeners() {
|
|
2126
|
-
return [...this._dataListeners];
|
|
2127
|
-
}
|
|
2128
|
-
get closeListeners() {
|
|
2129
|
-
return [...this._closeListeners];
|
|
2130
|
-
}
|
|
2131
|
-
get errorListeners() {
|
|
2132
|
-
return [...this._errorListeners];
|
|
2133
|
-
}
|
|
2095
|
+
dataListener;
|
|
2096
|
+
closeListener;
|
|
2097
|
+
errorListener;
|
|
2134
2098
|
onData(msg) {
|
|
2135
|
-
|
|
2136
|
-
cb(msg);
|
|
2137
|
-
}
|
|
2099
|
+
this.dataListener?.(msg);
|
|
2138
2100
|
}
|
|
2139
2101
|
onError(err) {
|
|
2140
|
-
|
|
2141
|
-
cb(err);
|
|
2142
|
-
}
|
|
2102
|
+
this.errorListener?.(err);
|
|
2143
2103
|
}
|
|
2144
2104
|
onClose() {
|
|
2145
|
-
|
|
2146
|
-
cb();
|
|
2147
|
-
}
|
|
2105
|
+
this.closeListener?.();
|
|
2148
2106
|
this.telemetry?.span.end();
|
|
2149
2107
|
}
|
|
2150
2108
|
/**
|
|
2151
|
-
*
|
|
2152
|
-
* @param
|
|
2109
|
+
* Set the callback for when a message is received.
|
|
2110
|
+
* @param cb The message handler callback.
|
|
2153
2111
|
*/
|
|
2154
|
-
|
|
2155
|
-
this.
|
|
2112
|
+
setDataListener(cb) {
|
|
2113
|
+
this.dataListener = cb;
|
|
2156
2114
|
}
|
|
2157
|
-
removeDataListener(
|
|
2158
|
-
this.
|
|
2115
|
+
removeDataListener() {
|
|
2116
|
+
this.dataListener = void 0;
|
|
2159
2117
|
}
|
|
2160
2118
|
/**
|
|
2161
|
-
*
|
|
2162
|
-
* This should also be called if an error happens and after notifying
|
|
2119
|
+
* Set the callback for when the connection is closed.
|
|
2120
|
+
* This should also be called if an error happens and after notifying the error listener.
|
|
2163
2121
|
* @param cb The callback to call when the connection is closed.
|
|
2164
2122
|
*/
|
|
2165
|
-
|
|
2166
|
-
this.
|
|
2123
|
+
setCloseListener(cb) {
|
|
2124
|
+
this.closeListener = cb;
|
|
2167
2125
|
}
|
|
2168
|
-
removeCloseListener(
|
|
2169
|
-
this.
|
|
2126
|
+
removeCloseListener() {
|
|
2127
|
+
this.closeListener = void 0;
|
|
2170
2128
|
}
|
|
2171
2129
|
/**
|
|
2172
|
-
*
|
|
2173
|
-
* This should only be used for
|
|
2174
|
-
* should be delegated to
|
|
2130
|
+
* Set the callback for when an error is received.
|
|
2131
|
+
* This should only be used for logging errors, all cleanup
|
|
2132
|
+
* should be delegated to setCloseListener.
|
|
2175
2133
|
*
|
|
2176
2134
|
* The implementer should take care such that the implemented
|
|
2177
2135
|
* connection will call both the close and error callbacks
|
|
@@ -2179,11 +2137,11 @@ var Connection = class {
|
|
|
2179
2137
|
*
|
|
2180
2138
|
* @param cb The callback to call when an error is received.
|
|
2181
2139
|
*/
|
|
2182
|
-
|
|
2183
|
-
this.
|
|
2140
|
+
setErrorListener(cb) {
|
|
2141
|
+
this.errorListener = cb;
|
|
2184
2142
|
}
|
|
2185
|
-
removeErrorListener(
|
|
2186
|
-
this.
|
|
2143
|
+
removeErrorListener() {
|
|
2144
|
+
this.errorListener = void 0;
|
|
2187
2145
|
}
|
|
2188
2146
|
};
|
|
2189
2147
|
|
|
@@ -2652,19 +2610,13 @@ var InMemoryConnection = class extends Connection {
|
|
|
2652
2610
|
this.conn = pipe;
|
|
2653
2611
|
this.conn.allowHalfOpen = false;
|
|
2654
2612
|
this.conn.on("data", (data) => {
|
|
2655
|
-
|
|
2656
|
-
cb(data);
|
|
2657
|
-
}
|
|
2613
|
+
this.dataListener?.(data);
|
|
2658
2614
|
});
|
|
2659
2615
|
this.conn.on("close", () => {
|
|
2660
|
-
|
|
2661
|
-
cb();
|
|
2662
|
-
}
|
|
2616
|
+
this.closeListener?.();
|
|
2663
2617
|
});
|
|
2664
2618
|
this.conn.on("error", (err) => {
|
|
2665
|
-
|
|
2666
|
-
cb(err);
|
|
2667
|
-
}
|
|
2619
|
+
this.errorListener?.(err);
|
|
2668
2620
|
});
|
|
2669
2621
|
}
|
|
2670
2622
|
send(payload) {
|
|
@@ -2747,8 +2699,7 @@ function createMockTransportNetwork(opts) {
|
|
|
2747
2699
|
},
|
|
2748
2700
|
async restartServer() {
|
|
2749
2701
|
for (const transport of transports) {
|
|
2750
|
-
if (transport.clientId !== "SERVER")
|
|
2751
|
-
continue;
|
|
2702
|
+
if (transport.clientId !== "SERVER") continue;
|
|
2752
2703
|
transport.close();
|
|
2753
2704
|
}
|
|
2754
2705
|
for (const conn of Object.values(connections.get())) {
|