@replit/river 0.13.9 → 0.14.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 +11 -3
- package/dist/{builder-4bc0351d.d.ts → builder-0547e840.d.ts} +1 -1
- package/dist/{chunk-ZIGZKCDJ.js → chunk-NJ25LQPI.js} +10 -18
- package/dist/{chunk-KUQ4OT4D.js → chunk-TVRCTAL2.js} +52 -48
- package/dist/{chunk-L62HCTWX.js → chunk-WYUFVZC3.js} +1 -1
- package/dist/{chunk-65O4MCJZ.js → chunk-ZD5NJJXR.js} +1 -1
- package/dist/{connection-ba6a843a.d.ts → connection-6c569569.d.ts} +1 -1
- package/dist/{connection-ede51542.d.ts → connection-ec72fdb0.d.ts} +1 -1
- package/dist/{index-56a709fc.d.ts → index-d1452d8f.d.ts} +3 -4
- package/dist/router/index.cjs +52 -48
- package/dist/router/index.d.cts +4 -4
- package/dist/router/index.d.ts +4 -4
- package/dist/router/index.js +1 -1
- package/dist/transport/impls/uds/client.cjs +12 -23
- package/dist/transport/impls/uds/client.d.cts +3 -4
- package/dist/transport/impls/uds/client.d.ts +3 -4
- package/dist/transport/impls/uds/client.js +4 -7
- package/dist/transport/impls/uds/server.cjs +4 -12
- 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 -2
- package/dist/transport/impls/ws/client.cjs +12 -30
- package/dist/transport/impls/ws/client.d.cts +3 -5
- package/dist/transport/impls/ws/client.d.ts +3 -5
- package/dist/transport/impls/ws/client.js +4 -14
- package/dist/transport/impls/ws/server.cjs +4 -12
- 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 +2 -2
- package/dist/transport/index.cjs +10 -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 +4 -12
- 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
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# River
|
|
2
|
+
|
|
3
|
+
## Long-lived Streaming Remote Procedure Calls
|
|
2
4
|
|
|
3
5
|
It's like tRPC/gRPC but with
|
|
4
6
|
|
|
@@ -23,6 +25,9 @@ npm i @replit/river @sinclair/typebox
|
|
|
23
25
|
npm i ws isomorphic-ws
|
|
24
26
|
```
|
|
25
27
|
|
|
28
|
+
If you are planning on using River with React, also check out [`@replit/river-react`](https://npmjs.com/package/@replit/river-react)
|
|
29
|
+
which provides some handy hooks and contexts for playing nicely with the React lifecycle.
|
|
30
|
+
|
|
26
31
|
## Writing Services
|
|
27
32
|
|
|
28
33
|
### Concepts
|
|
@@ -103,10 +108,13 @@ const websocketUrl = `ws://localhost:3000`;
|
|
|
103
108
|
const transport = new WebSocketClientTransport(
|
|
104
109
|
async () => new WebSocket(websocketUrl),
|
|
105
110
|
'my-client-id',
|
|
106
|
-
'SERVER',
|
|
107
111
|
);
|
|
108
112
|
|
|
109
|
-
const client = createClient<ServiceSurface>(
|
|
113
|
+
const client = createClient<ServiceSurface>(
|
|
114
|
+
transport,
|
|
115
|
+
'SERVER', // transport id of the server in the previous step
|
|
116
|
+
true, // whether to eagerly connect to the server on creation (optional argument)
|
|
117
|
+
);
|
|
110
118
|
|
|
111
119
|
// we get full type safety on `client`
|
|
112
120
|
// client.<service name>.<procedure name>.<procedure type>()
|
|
@@ -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-d1452d8f.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The context for services/procedures. This is used only on
|
|
@@ -80,11 +80,11 @@ var Session = class {
|
|
|
80
80
|
*/
|
|
81
81
|
debugId;
|
|
82
82
|
/**
|
|
83
|
-
* Number of messages we've sent along this session (excluding handshake)
|
|
83
|
+
* Number of messages we've sent along this session (excluding handshake and acks)
|
|
84
84
|
*/
|
|
85
85
|
seq = 0;
|
|
86
86
|
/**
|
|
87
|
-
* Number of unique messages we've received this session (excluding handshake)
|
|
87
|
+
* Number of unique messages we've received this session (excluding handshake and acks)
|
|
88
88
|
*/
|
|
89
89
|
ack = 0;
|
|
90
90
|
/**
|
|
@@ -148,21 +148,13 @@ var Session = class {
|
|
|
148
148
|
}
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
return;
|
|
153
|
-
const heartbeatBuff = {
|
|
154
|
-
id: unsafeId(),
|
|
155
|
-
to: this.to,
|
|
156
|
-
from: this.from,
|
|
157
|
-
seq: this.seq,
|
|
158
|
-
ack: this.ack,
|
|
151
|
+
this.send({
|
|
159
152
|
streamId: "heartbeat",
|
|
160
153
|
controlFlags: 1 /* AckBit */,
|
|
161
154
|
payload: {
|
|
162
155
|
type: "ACK"
|
|
163
156
|
}
|
|
164
|
-
};
|
|
165
|
-
this.connection.send(this.codec.toBuffer(heartbeatBuff));
|
|
157
|
+
});
|
|
166
158
|
this.heartbeatMisses++;
|
|
167
159
|
}
|
|
168
160
|
resetBufferedMessages() {
|
|
@@ -538,10 +530,8 @@ var ClientTransport = class extends Transport {
|
|
|
538
530
|
*/
|
|
539
531
|
inflightConnectionPromises;
|
|
540
532
|
tryReconnecting = true;
|
|
541
|
-
|
|
542
|
-
constructor(clientId, connectedTo, providedOptions) {
|
|
533
|
+
constructor(clientId, providedOptions) {
|
|
543
534
|
super(clientId, providedOptions);
|
|
544
|
-
this.connectedTo = connectedTo;
|
|
545
535
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
546
536
|
}
|
|
547
537
|
handleConnection(conn, to) {
|
|
@@ -620,12 +610,14 @@ var ClientTransport = class extends Transport {
|
|
|
620
610
|
}
|
|
621
611
|
let reconnectPromise = this.inflightConnectionPromises.get(to);
|
|
622
612
|
if (!reconnectPromise) {
|
|
623
|
-
reconnectPromise = this.createNewOutgoingConnection(to)
|
|
613
|
+
reconnectPromise = this.createNewOutgoingConnection(to).then((conn) => {
|
|
614
|
+
this.sendHandshake(to, conn);
|
|
615
|
+
return conn;
|
|
616
|
+
});
|
|
624
617
|
this.inflightConnectionPromises.set(to, reconnectPromise);
|
|
625
618
|
}
|
|
626
619
|
try {
|
|
627
|
-
|
|
628
|
-
this.sendHandshake(to, conn);
|
|
620
|
+
await reconnectPromise;
|
|
629
621
|
} catch (error) {
|
|
630
622
|
const errStr = coerceErrorString(error);
|
|
631
623
|
this.inflightConnectionPromises.delete(to);
|
|
@@ -428,56 +428,60 @@ function _createRecursiveProxy(callback, path) {
|
|
|
428
428
|
});
|
|
429
429
|
return proxy;
|
|
430
430
|
}
|
|
431
|
-
var createClient = (transport
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
if (!(serviceName && procName && procType)) {
|
|
435
|
-
throw new Error(
|
|
436
|
-
"invalid river call, ensure the service and procedure you are calling exists"
|
|
437
|
-
);
|
|
431
|
+
var createClient = (transport, serverId, eagerlyConnect = true) => {
|
|
432
|
+
if (eagerlyConnect) {
|
|
433
|
+
void transport.connect(serverId);
|
|
438
434
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
procName
|
|
452
|
-
);
|
|
453
|
-
} else if (procType === "stream") {
|
|
454
|
-
return handleStream(
|
|
455
|
-
transport,
|
|
456
|
-
serverId,
|
|
457
|
-
input,
|
|
458
|
-
serviceName,
|
|
459
|
-
procName
|
|
460
|
-
);
|
|
461
|
-
} else if (procType === "subscribe") {
|
|
462
|
-
return handleSubscribe(
|
|
463
|
-
transport,
|
|
464
|
-
serverId,
|
|
465
|
-
input,
|
|
466
|
-
serviceName,
|
|
467
|
-
procName
|
|
468
|
-
);
|
|
469
|
-
} else if (procType === "upload") {
|
|
470
|
-
return handleUpload(
|
|
471
|
-
transport,
|
|
472
|
-
serverId,
|
|
473
|
-
input,
|
|
474
|
-
serviceName,
|
|
475
|
-
procName
|
|
435
|
+
return _createRecursiveProxy(async (opts) => {
|
|
436
|
+
const [serviceName, procName, procType] = [...opts.path];
|
|
437
|
+
if (!(serviceName && procName && procType)) {
|
|
438
|
+
throw new Error(
|
|
439
|
+
"invalid river call, ensure the service and procedure you are calling exists"
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
const [input] = opts.args;
|
|
443
|
+
log?.info(
|
|
444
|
+
`${transport.clientId} -- invoked ${procType}: ${serviceName}.${procName} with args: ${JSON.stringify(
|
|
445
|
+
input
|
|
446
|
+
)}`
|
|
476
447
|
);
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
448
|
+
if (procType === "rpc") {
|
|
449
|
+
return handleRpc(
|
|
450
|
+
transport,
|
|
451
|
+
serverId,
|
|
452
|
+
input,
|
|
453
|
+
serviceName,
|
|
454
|
+
procName
|
|
455
|
+
);
|
|
456
|
+
} else if (procType === "stream") {
|
|
457
|
+
return handleStream(
|
|
458
|
+
transport,
|
|
459
|
+
serverId,
|
|
460
|
+
input,
|
|
461
|
+
serviceName,
|
|
462
|
+
procName
|
|
463
|
+
);
|
|
464
|
+
} else if (procType === "subscribe") {
|
|
465
|
+
return handleSubscribe(
|
|
466
|
+
transport,
|
|
467
|
+
serverId,
|
|
468
|
+
input,
|
|
469
|
+
serviceName,
|
|
470
|
+
procName
|
|
471
|
+
);
|
|
472
|
+
} else if (procType === "upload") {
|
|
473
|
+
return handleUpload(
|
|
474
|
+
transport,
|
|
475
|
+
serverId,
|
|
476
|
+
input,
|
|
477
|
+
serviceName,
|
|
478
|
+
procName
|
|
479
|
+
);
|
|
480
|
+
} else {
|
|
481
|
+
throw new Error(`invalid river call, unknown procedure type ${procType}`);
|
|
482
|
+
}
|
|
483
|
+
}, []);
|
|
484
|
+
};
|
|
481
485
|
function createSessionDisconnectHandler(from, cb) {
|
|
482
486
|
return (evt) => {
|
|
483
487
|
if (evt.status === "disconnect" && evt.session.to === from) {
|
|
@@ -159,11 +159,11 @@ declare class Session<ConnType extends Connection> {
|
|
|
159
159
|
*/
|
|
160
160
|
debugId: string;
|
|
161
161
|
/**
|
|
162
|
-
* Number of messages we've sent along this session (excluding handshake)
|
|
162
|
+
* Number of messages we've sent along this session (excluding handshake and acks)
|
|
163
163
|
*/
|
|
164
164
|
private seq;
|
|
165
165
|
/**
|
|
166
|
-
* Number of unique messages we've received this session (excluding handshake)
|
|
166
|
+
* Number of unique messages we've received this session (excluding handshake and acks)
|
|
167
167
|
*/
|
|
168
168
|
private ack;
|
|
169
169
|
/**
|
|
@@ -386,8 +386,7 @@ declare abstract class ClientTransport<ConnType extends Connection> extends Tran
|
|
|
386
386
|
*/
|
|
387
387
|
inflightConnectionPromises: Map<TransportClientId, Promise<ConnType>>;
|
|
388
388
|
tryReconnecting: boolean;
|
|
389
|
-
|
|
390
|
-
constructor(clientId: TransportClientId, connectedTo: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
389
|
+
constructor(clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
391
390
|
protected handleConnection(conn: ConnType, to: TransportClientId): void;
|
|
392
391
|
receiveHandshakeResponseMessage(data: Uint8Array): false | {
|
|
393
392
|
instanceId: string;
|
package/dist/router/index.cjs
CHANGED
|
@@ -514,56 +514,60 @@ function _createRecursiveProxy(callback, path) {
|
|
|
514
514
|
});
|
|
515
515
|
return proxy;
|
|
516
516
|
}
|
|
517
|
-
var createClient = (transport
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
if (!(serviceName && procName && procType)) {
|
|
521
|
-
throw new Error(
|
|
522
|
-
"invalid river call, ensure the service and procedure you are calling exists"
|
|
523
|
-
);
|
|
517
|
+
var createClient = (transport, serverId, eagerlyConnect = true) => {
|
|
518
|
+
if (eagerlyConnect) {
|
|
519
|
+
void transport.connect(serverId);
|
|
524
520
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
procName
|
|
538
|
-
);
|
|
539
|
-
} else if (procType === "stream") {
|
|
540
|
-
return handleStream(
|
|
541
|
-
transport,
|
|
542
|
-
serverId,
|
|
543
|
-
input,
|
|
544
|
-
serviceName,
|
|
545
|
-
procName
|
|
546
|
-
);
|
|
547
|
-
} else if (procType === "subscribe") {
|
|
548
|
-
return handleSubscribe(
|
|
549
|
-
transport,
|
|
550
|
-
serverId,
|
|
551
|
-
input,
|
|
552
|
-
serviceName,
|
|
553
|
-
procName
|
|
554
|
-
);
|
|
555
|
-
} else if (procType === "upload") {
|
|
556
|
-
return handleUpload(
|
|
557
|
-
transport,
|
|
558
|
-
serverId,
|
|
559
|
-
input,
|
|
560
|
-
serviceName,
|
|
561
|
-
procName
|
|
521
|
+
return _createRecursiveProxy(async (opts) => {
|
|
522
|
+
const [serviceName, procName, procType] = [...opts.path];
|
|
523
|
+
if (!(serviceName && procName && procType)) {
|
|
524
|
+
throw new Error(
|
|
525
|
+
"invalid river call, ensure the service and procedure you are calling exists"
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
const [input] = opts.args;
|
|
529
|
+
log?.info(
|
|
530
|
+
`${transport.clientId} -- invoked ${procType}: ${serviceName}.${procName} with args: ${JSON.stringify(
|
|
531
|
+
input
|
|
532
|
+
)}`
|
|
562
533
|
);
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
534
|
+
if (procType === "rpc") {
|
|
535
|
+
return handleRpc(
|
|
536
|
+
transport,
|
|
537
|
+
serverId,
|
|
538
|
+
input,
|
|
539
|
+
serviceName,
|
|
540
|
+
procName
|
|
541
|
+
);
|
|
542
|
+
} else if (procType === "stream") {
|
|
543
|
+
return handleStream(
|
|
544
|
+
transport,
|
|
545
|
+
serverId,
|
|
546
|
+
input,
|
|
547
|
+
serviceName,
|
|
548
|
+
procName
|
|
549
|
+
);
|
|
550
|
+
} else if (procType === "subscribe") {
|
|
551
|
+
return handleSubscribe(
|
|
552
|
+
transport,
|
|
553
|
+
serverId,
|
|
554
|
+
input,
|
|
555
|
+
serviceName,
|
|
556
|
+
procName
|
|
557
|
+
);
|
|
558
|
+
} else if (procType === "upload") {
|
|
559
|
+
return handleUpload(
|
|
560
|
+
transport,
|
|
561
|
+
serverId,
|
|
562
|
+
input,
|
|
563
|
+
serviceName,
|
|
564
|
+
procName
|
|
565
|
+
);
|
|
566
|
+
} else {
|
|
567
|
+
throw new Error(`invalid river call, unknown procedure type ${procType}`);
|
|
568
|
+
}
|
|
569
|
+
}, []);
|
|
570
|
+
};
|
|
567
571
|
function createSessionDisconnectHandler(from, cb) {
|
|
568
572
|
return (evt) => {
|
|
569
573
|
if (evt.status === "disconnect" && evt.session.to === from) {
|
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-0547e840.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-0547e840.js';
|
|
3
|
+
import { S as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-d1452d8f.js';
|
|
4
4
|
import { Pushable } from 'it-pushable';
|
|
5
5
|
import { Static } from '@sinclair/typebox';
|
|
6
6
|
import '../types-3e5768ec.js';
|
|
@@ -110,6 +110,6 @@ type ServerClient<Srv extends Server<ServiceDefs>> = {
|
|
|
110
110
|
* @param {Transport} transport - The transport to use for communication.
|
|
111
111
|
* @returns The client for the server.
|
|
112
112
|
*/
|
|
113
|
-
declare const createClient: <Srv extends Server<ServiceDefs>>(transport: ClientTransport<Connection
|
|
113
|
+
declare const createClient: <Srv extends Server<ServiceDefs>>(transport: ClientTransport<Connection>, serverId: TransportClientId, eagerlyConnect?: boolean) => ServerClient<Srv>;
|
|
114
114
|
|
|
115
115
|
export { PayloadType, ProcInput, ProcOutput, ProcType, Result, RiverError, Server, ServerClient, ServiceContext, ServiceDefs, buildServiceDefs, createClient, createServer };
|
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-0547e840.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-0547e840.js';
|
|
3
|
+
import { S as ServerTransport, C as Connection, a as ClientTransport, b as TransportClientId } from '../index-d1452d8f.js';
|
|
4
4
|
import { Pushable } from 'it-pushable';
|
|
5
5
|
import { Static } from '@sinclair/typebox';
|
|
6
6
|
import '../types-3e5768ec.js';
|
|
@@ -110,6 +110,6 @@ type ServerClient<Srv extends Server<ServiceDefs>> = {
|
|
|
110
110
|
* @param {Transport} transport - The transport to use for communication.
|
|
111
111
|
* @returns The client for the server.
|
|
112
112
|
*/
|
|
113
|
-
declare const createClient: <Srv extends Server<ServiceDefs>>(transport: ClientTransport<Connection
|
|
113
|
+
declare const createClient: <Srv extends Server<ServiceDefs>>(transport: ClientTransport<Connection>, serverId: TransportClientId, eagerlyConnect?: boolean) => ServerClient<Srv>;
|
|
114
114
|
|
|
115
115
|
export { PayloadType, ProcInput, ProcOutput, ProcType, Result, RiverError, Server, ServerClient, ServiceContext, ServiceDefs, buildServiceDefs, createClient, createServer };
|
package/dist/router/index.js
CHANGED
|
@@ -188,11 +188,11 @@ var Session = class {
|
|
|
188
188
|
*/
|
|
189
189
|
debugId;
|
|
190
190
|
/**
|
|
191
|
-
* Number of messages we've sent along this session (excluding handshake)
|
|
191
|
+
* Number of messages we've sent along this session (excluding handshake and acks)
|
|
192
192
|
*/
|
|
193
193
|
seq = 0;
|
|
194
194
|
/**
|
|
195
|
-
* Number of unique messages we've received this session (excluding handshake)
|
|
195
|
+
* Number of unique messages we've received this session (excluding handshake and acks)
|
|
196
196
|
*/
|
|
197
197
|
ack = 0;
|
|
198
198
|
/**
|
|
@@ -256,21 +256,13 @@ var Session = class {
|
|
|
256
256
|
}
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
|
-
|
|
260
|
-
return;
|
|
261
|
-
const heartbeatBuff = {
|
|
262
|
-
id: unsafeId(),
|
|
263
|
-
to: this.to,
|
|
264
|
-
from: this.from,
|
|
265
|
-
seq: this.seq,
|
|
266
|
-
ack: this.ack,
|
|
259
|
+
this.send({
|
|
267
260
|
streamId: "heartbeat",
|
|
268
261
|
controlFlags: 1 /* AckBit */,
|
|
269
262
|
payload: {
|
|
270
263
|
type: "ACK"
|
|
271
264
|
}
|
|
272
|
-
};
|
|
273
|
-
this.connection.send(this.codec.toBuffer(heartbeatBuff));
|
|
265
|
+
});
|
|
274
266
|
this.heartbeatMisses++;
|
|
275
267
|
}
|
|
276
268
|
resetBufferedMessages() {
|
|
@@ -779,10 +771,8 @@ var ClientTransport = class extends Transport {
|
|
|
779
771
|
*/
|
|
780
772
|
inflightConnectionPromises;
|
|
781
773
|
tryReconnecting = true;
|
|
782
|
-
|
|
783
|
-
constructor(clientId, connectedTo, providedOptions) {
|
|
774
|
+
constructor(clientId, providedOptions) {
|
|
784
775
|
super(clientId, providedOptions);
|
|
785
|
-
this.connectedTo = connectedTo;
|
|
786
776
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
787
777
|
}
|
|
788
778
|
handleConnection(conn, to) {
|
|
@@ -861,12 +851,14 @@ var ClientTransport = class extends Transport {
|
|
|
861
851
|
}
|
|
862
852
|
let reconnectPromise = this.inflightConnectionPromises.get(to);
|
|
863
853
|
if (!reconnectPromise) {
|
|
864
|
-
reconnectPromise = this.createNewOutgoingConnection(to)
|
|
854
|
+
reconnectPromise = this.createNewOutgoingConnection(to).then((conn) => {
|
|
855
|
+
this.sendHandshake(to, conn);
|
|
856
|
+
return conn;
|
|
857
|
+
});
|
|
865
858
|
this.inflightConnectionPromises.set(to, reconnectPromise);
|
|
866
859
|
}
|
|
867
860
|
try {
|
|
868
|
-
|
|
869
|
-
this.sendHandshake(to, conn);
|
|
861
|
+
await reconnectPromise;
|
|
870
862
|
} catch (error) {
|
|
871
863
|
const errStr = coerceErrorString(error);
|
|
872
864
|
this.inflightConnectionPromises.delete(to);
|
|
@@ -905,12 +897,9 @@ var ClientTransport = class extends Transport {
|
|
|
905
897
|
// transport/impls/uds/client.ts
|
|
906
898
|
var UnixDomainSocketClientTransport = class extends ClientTransport {
|
|
907
899
|
path;
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
super(clientId, serverId, providedOptions);
|
|
900
|
+
constructor(socketPath, clientId, providedOptions) {
|
|
901
|
+
super(clientId, providedOptions);
|
|
911
902
|
this.path = socketPath;
|
|
912
|
-
this.serverId = serverId;
|
|
913
|
-
void this.connect(serverId);
|
|
914
903
|
}
|
|
915
904
|
async createNewOutgoingConnection(to) {
|
|
916
905
|
const oldConnection = this.connections.get(to);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClientTransport,
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { a as ClientTransport, c as TransportOptions, b as TransportClientId } from '../../../index-d1452d8f.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-6c569569.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -7,8 +7,7 @@ import 'node:stream';
|
|
|
7
7
|
|
|
8
8
|
declare class UnixDomainSocketClientTransport extends ClientTransport<UdsConnection> {
|
|
9
9
|
path: string;
|
|
10
|
-
|
|
11
|
-
constructor(socketPath: string, clientId: string, serverId: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
10
|
+
constructor(socketPath: string, clientId: string, providedOptions?: Partial<TransportOptions>);
|
|
12
11
|
createNewOutgoingConnection(to: TransportClientId): Promise<UdsConnection>;
|
|
13
12
|
}
|
|
14
13
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ClientTransport,
|
|
2
|
-
import { U as UdsConnection } from '../../../connection-
|
|
1
|
+
import { a as ClientTransport, c as TransportOptions, b as TransportClientId } from '../../../index-d1452d8f.js';
|
|
2
|
+
import { U as UdsConnection } from '../../../connection-6c569569.js';
|
|
3
3
|
import '../../../types-3e5768ec.js';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import 'node:net';
|
|
@@ -7,8 +7,7 @@ import 'node:stream';
|
|
|
7
7
|
|
|
8
8
|
declare class UnixDomainSocketClientTransport extends ClientTransport<UdsConnection> {
|
|
9
9
|
path: string;
|
|
10
|
-
|
|
11
|
-
constructor(socketPath: string, clientId: string, serverId: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
10
|
+
constructor(socketPath: string, clientId: string, providedOptions?: Partial<TransportOptions>);
|
|
12
11
|
createNewOutgoingConnection(to: TransportClientId): Promise<UdsConnection>;
|
|
13
12
|
}
|
|
14
13
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
UdsConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-ZD5NJJXR.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NJ25LQPI.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -14,12 +14,9 @@ import "../../../chunk-GZ7HCLLM.js";
|
|
|
14
14
|
import { Socket } from "node:net";
|
|
15
15
|
var UnixDomainSocketClientTransport = class extends ClientTransport {
|
|
16
16
|
path;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
super(clientId, serverId, providedOptions);
|
|
17
|
+
constructor(socketPath, clientId, providedOptions) {
|
|
18
|
+
super(clientId, providedOptions);
|
|
20
19
|
this.path = socketPath;
|
|
21
|
-
this.serverId = serverId;
|
|
22
|
-
void this.connect(serverId);
|
|
23
20
|
}
|
|
24
21
|
async createNewOutgoingConnection(to) {
|
|
25
22
|
const oldConnection = this.connections.get(to);
|
|
@@ -226,11 +226,11 @@ var Session = class {
|
|
|
226
226
|
*/
|
|
227
227
|
debugId;
|
|
228
228
|
/**
|
|
229
|
-
* Number of messages we've sent along this session (excluding handshake)
|
|
229
|
+
* Number of messages we've sent along this session (excluding handshake and acks)
|
|
230
230
|
*/
|
|
231
231
|
seq = 0;
|
|
232
232
|
/**
|
|
233
|
-
* Number of unique messages we've received this session (excluding handshake)
|
|
233
|
+
* Number of unique messages we've received this session (excluding handshake and acks)
|
|
234
234
|
*/
|
|
235
235
|
ack = 0;
|
|
236
236
|
/**
|
|
@@ -294,21 +294,13 @@ var Session = class {
|
|
|
294
294
|
}
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
-
|
|
298
|
-
return;
|
|
299
|
-
const heartbeatBuff = {
|
|
300
|
-
id: unsafeId(),
|
|
301
|
-
to: this.to,
|
|
302
|
-
from: this.from,
|
|
303
|
-
seq: this.seq,
|
|
304
|
-
ack: this.ack,
|
|
297
|
+
this.send({
|
|
305
298
|
streamId: "heartbeat",
|
|
306
299
|
controlFlags: 1 /* AckBit */,
|
|
307
300
|
payload: {
|
|
308
301
|
type: "ACK"
|
|
309
302
|
}
|
|
310
|
-
};
|
|
311
|
-
this.connection.send(this.codec.toBuffer(heartbeatBuff));
|
|
303
|
+
});
|
|
312
304
|
this.heartbeatMisses++;
|
|
313
305
|
}
|
|
314
306
|
resetBufferedMessages() {
|
|
@@ -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-d1452d8f.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-6c569569.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-d1452d8f.js';
|
|
3
|
+
import { U as UdsConnection } from '../../../connection-6c569569.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-ZD5NJJXR.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NJ25LQPI.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -218,11 +218,11 @@ var Session = class {
|
|
|
218
218
|
*/
|
|
219
219
|
debugId;
|
|
220
220
|
/**
|
|
221
|
-
* Number of messages we've sent along this session (excluding handshake)
|
|
221
|
+
* Number of messages we've sent along this session (excluding handshake and acks)
|
|
222
222
|
*/
|
|
223
223
|
seq = 0;
|
|
224
224
|
/**
|
|
225
|
-
* Number of unique messages we've received this session (excluding handshake)
|
|
225
|
+
* Number of unique messages we've received this session (excluding handshake and acks)
|
|
226
226
|
*/
|
|
227
227
|
ack = 0;
|
|
228
228
|
/**
|
|
@@ -286,21 +286,13 @@ var Session = class {
|
|
|
286
286
|
}
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
|
-
|
|
290
|
-
return;
|
|
291
|
-
const heartbeatBuff = {
|
|
292
|
-
id: unsafeId(),
|
|
293
|
-
to: this.to,
|
|
294
|
-
from: this.from,
|
|
295
|
-
seq: this.seq,
|
|
296
|
-
ack: this.ack,
|
|
289
|
+
this.send({
|
|
297
290
|
streamId: "heartbeat",
|
|
298
291
|
controlFlags: 1 /* AckBit */,
|
|
299
292
|
payload: {
|
|
300
293
|
type: "ACK"
|
|
301
294
|
}
|
|
302
|
-
};
|
|
303
|
-
this.connection.send(this.codec.toBuffer(heartbeatBuff));
|
|
295
|
+
});
|
|
304
296
|
this.heartbeatMisses++;
|
|
305
297
|
}
|
|
306
298
|
resetBufferedMessages() {
|
|
@@ -685,10 +677,8 @@ var ClientTransport = class extends Transport {
|
|
|
685
677
|
*/
|
|
686
678
|
inflightConnectionPromises;
|
|
687
679
|
tryReconnecting = true;
|
|
688
|
-
|
|
689
|
-
constructor(clientId, connectedTo, providedOptions) {
|
|
680
|
+
constructor(clientId, providedOptions) {
|
|
690
681
|
super(clientId, providedOptions);
|
|
691
|
-
this.connectedTo = connectedTo;
|
|
692
682
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
693
683
|
}
|
|
694
684
|
handleConnection(conn, to) {
|
|
@@ -767,12 +757,14 @@ var ClientTransport = class extends Transport {
|
|
|
767
757
|
}
|
|
768
758
|
let reconnectPromise = this.inflightConnectionPromises.get(to);
|
|
769
759
|
if (!reconnectPromise) {
|
|
770
|
-
reconnectPromise = this.createNewOutgoingConnection(to)
|
|
760
|
+
reconnectPromise = this.createNewOutgoingConnection(to).then((conn) => {
|
|
761
|
+
this.sendHandshake(to, conn);
|
|
762
|
+
return conn;
|
|
763
|
+
});
|
|
771
764
|
this.inflightConnectionPromises.set(to, reconnectPromise);
|
|
772
765
|
}
|
|
773
766
|
try {
|
|
774
|
-
|
|
775
|
-
this.sendHandshake(to, conn);
|
|
767
|
+
await reconnectPromise;
|
|
776
768
|
} catch (error) {
|
|
777
769
|
const errStr = coerceErrorString(error);
|
|
778
770
|
this.inflightConnectionPromises.delete(to);
|
|
@@ -847,7 +839,6 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
847
839
|
* A function that returns a Promise that resolves to a WebSocket instance.
|
|
848
840
|
*/
|
|
849
841
|
wsGetter;
|
|
850
|
-
serverId;
|
|
851
842
|
/**
|
|
852
843
|
* Creates a new WebSocketClientTransport instance.
|
|
853
844
|
* @param wsGetter A function that returns a Promise that resolves to a WebSocket instance.
|
|
@@ -855,18 +846,9 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
855
846
|
* @param serverId The ID of the server this transport is connecting to.
|
|
856
847
|
* @param providedOptions An optional object containing configuration options for the transport.
|
|
857
848
|
*/
|
|
858
|
-
constructor(wsGetter, clientId,
|
|
859
|
-
super(clientId,
|
|
849
|
+
constructor(wsGetter, clientId, providedOptions) {
|
|
850
|
+
super(clientId, providedOptions);
|
|
860
851
|
this.wsGetter = wsGetter;
|
|
861
|
-
this.serverId = serverId;
|
|
862
|
-
void this.connect(this.serverId);
|
|
863
|
-
}
|
|
864
|
-
reopen() {
|
|
865
|
-
if (this.state === "destroyed") {
|
|
866
|
-
throw new Error("cant reopen a destroyed connection");
|
|
867
|
-
}
|
|
868
|
-
this.state = "open";
|
|
869
|
-
void this.connect(this.serverId);
|
|
870
852
|
}
|
|
871
853
|
async createNewOutgoingConnection(to) {
|
|
872
854
|
const wsRes = await new Promise((resolve) => {
|
|
@@ -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-d1452d8f.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-ec72fdb0.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
|
|
@@ -14,7 +14,6 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
|
|
|
14
14
|
* A function that returns a Promise that resolves to a WebSocket instance.
|
|
15
15
|
*/
|
|
16
16
|
wsGetter: (to: TransportClientId) => Promise<WebSocket>;
|
|
17
|
-
serverId: TransportClientId;
|
|
18
17
|
/**
|
|
19
18
|
* Creates a new WebSocketClientTransport instance.
|
|
20
19
|
* @param wsGetter A function that returns a Promise that resolves to a WebSocket instance.
|
|
@@ -22,8 +21,7 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
|
|
|
22
21
|
* @param serverId The ID of the server this transport is connecting to.
|
|
23
22
|
* @param providedOptions An optional object containing configuration options for the transport.
|
|
24
23
|
*/
|
|
25
|
-
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId,
|
|
26
|
-
reopen(): void;
|
|
24
|
+
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
27
25
|
createNewOutgoingConnection(to: string): Promise<WebSocketConnection>;
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -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-d1452d8f.js';
|
|
3
|
+
import { W as WebSocketConnection } from '../../../connection-ec72fdb0.js';
|
|
4
4
|
import '../../../types-3e5768ec.js';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
|
|
@@ -14,7 +14,6 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
|
|
|
14
14
|
* A function that returns a Promise that resolves to a WebSocket instance.
|
|
15
15
|
*/
|
|
16
16
|
wsGetter: (to: TransportClientId) => Promise<WebSocket>;
|
|
17
|
-
serverId: TransportClientId;
|
|
18
17
|
/**
|
|
19
18
|
* Creates a new WebSocketClientTransport instance.
|
|
20
19
|
* @param wsGetter A function that returns a Promise that resolves to a WebSocket instance.
|
|
@@ -22,8 +21,7 @@ declare class WebSocketClientTransport extends ClientTransport<WebSocketConnecti
|
|
|
22
21
|
* @param serverId The ID of the server this transport is connecting to.
|
|
23
22
|
* @param providedOptions An optional object containing configuration options for the transport.
|
|
24
23
|
*/
|
|
25
|
-
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId,
|
|
26
|
-
reopen(): void;
|
|
24
|
+
constructor(wsGetter: () => Promise<WebSocket>, clientId: TransportClientId, providedOptions?: Partial<TransportOptions>);
|
|
27
25
|
createNewOutgoingConnection(to: string): Promise<WebSocketConnection>;
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-WYUFVZC3.js";
|
|
4
4
|
import {
|
|
5
5
|
ClientTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NJ25LQPI.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import {
|
|
9
9
|
log
|
|
@@ -16,7 +16,6 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
16
16
|
* A function that returns a Promise that resolves to a WebSocket instance.
|
|
17
17
|
*/
|
|
18
18
|
wsGetter;
|
|
19
|
-
serverId;
|
|
20
19
|
/**
|
|
21
20
|
* Creates a new WebSocketClientTransport instance.
|
|
22
21
|
* @param wsGetter A function that returns a Promise that resolves to a WebSocket instance.
|
|
@@ -24,18 +23,9 @@ var WebSocketClientTransport = class extends ClientTransport {
|
|
|
24
23
|
* @param serverId The ID of the server this transport is connecting to.
|
|
25
24
|
* @param providedOptions An optional object containing configuration options for the transport.
|
|
26
25
|
*/
|
|
27
|
-
constructor(wsGetter, clientId,
|
|
28
|
-
super(clientId,
|
|
26
|
+
constructor(wsGetter, clientId, providedOptions) {
|
|
27
|
+
super(clientId, providedOptions);
|
|
29
28
|
this.wsGetter = wsGetter;
|
|
30
|
-
this.serverId = serverId;
|
|
31
|
-
void this.connect(this.serverId);
|
|
32
|
-
}
|
|
33
|
-
reopen() {
|
|
34
|
-
if (this.state === "destroyed") {
|
|
35
|
-
throw new Error("cant reopen a destroyed connection");
|
|
36
|
-
}
|
|
37
|
-
this.state = "open";
|
|
38
|
-
void this.connect(this.serverId);
|
|
39
29
|
}
|
|
40
30
|
async createNewOutgoingConnection(to) {
|
|
41
31
|
const wsRes = await new Promise((resolve) => {
|
|
@@ -226,11 +226,11 @@ var Session = class {
|
|
|
226
226
|
*/
|
|
227
227
|
debugId;
|
|
228
228
|
/**
|
|
229
|
-
* Number of messages we've sent along this session (excluding handshake)
|
|
229
|
+
* Number of messages we've sent along this session (excluding handshake and acks)
|
|
230
230
|
*/
|
|
231
231
|
seq = 0;
|
|
232
232
|
/**
|
|
233
|
-
* Number of unique messages we've received this session (excluding handshake)
|
|
233
|
+
* Number of unique messages we've received this session (excluding handshake and acks)
|
|
234
234
|
*/
|
|
235
235
|
ack = 0;
|
|
236
236
|
/**
|
|
@@ -294,21 +294,13 @@ var Session = class {
|
|
|
294
294
|
}
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
-
|
|
298
|
-
return;
|
|
299
|
-
const heartbeatBuff = {
|
|
300
|
-
id: unsafeId(),
|
|
301
|
-
to: this.to,
|
|
302
|
-
from: this.from,
|
|
303
|
-
seq: this.seq,
|
|
304
|
-
ack: this.ack,
|
|
297
|
+
this.send({
|
|
305
298
|
streamId: "heartbeat",
|
|
306
299
|
controlFlags: 1 /* AckBit */,
|
|
307
300
|
payload: {
|
|
308
301
|
type: "ACK"
|
|
309
302
|
}
|
|
310
|
-
};
|
|
311
|
-
this.connection.send(this.codec.toBuffer(heartbeatBuff));
|
|
303
|
+
});
|
|
312
304
|
this.heartbeatMisses++;
|
|
313
305
|
}
|
|
314
306
|
resetBufferedMessages() {
|
|
@@ -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-d1452d8f.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-ec72fdb0.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-d1452d8f.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-ec72fdb0.js';
|
|
5
5
|
import '../../../types-3e5768ec.js';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WebSocketConnection
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-WYUFVZC3.js";
|
|
4
4
|
import {
|
|
5
5
|
ServerTransport
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-NJ25LQPI.js";
|
|
7
7
|
import "../../../chunk-GFRAOY75.js";
|
|
8
8
|
import "../../../chunk-H4BYJELI.js";
|
|
9
9
|
import "../../../chunk-GZ7HCLLM.js";
|
package/dist/transport/index.cjs
CHANGED
|
@@ -248,11 +248,11 @@ var Session = class {
|
|
|
248
248
|
*/
|
|
249
249
|
debugId;
|
|
250
250
|
/**
|
|
251
|
-
* Number of messages we've sent along this session (excluding handshake)
|
|
251
|
+
* Number of messages we've sent along this session (excluding handshake and acks)
|
|
252
252
|
*/
|
|
253
253
|
seq = 0;
|
|
254
254
|
/**
|
|
255
|
-
* Number of unique messages we've received this session (excluding handshake)
|
|
255
|
+
* Number of unique messages we've received this session (excluding handshake and acks)
|
|
256
256
|
*/
|
|
257
257
|
ack = 0;
|
|
258
258
|
/**
|
|
@@ -316,21 +316,13 @@ var Session = class {
|
|
|
316
316
|
}
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
319
|
-
|
|
320
|
-
return;
|
|
321
|
-
const heartbeatBuff = {
|
|
322
|
-
id: unsafeId(),
|
|
323
|
-
to: this.to,
|
|
324
|
-
from: this.from,
|
|
325
|
-
seq: this.seq,
|
|
326
|
-
ack: this.ack,
|
|
319
|
+
this.send({
|
|
327
320
|
streamId: "heartbeat",
|
|
328
321
|
controlFlags: 1 /* AckBit */,
|
|
329
322
|
payload: {
|
|
330
323
|
type: "ACK"
|
|
331
324
|
}
|
|
332
|
-
};
|
|
333
|
-
this.connection.send(this.codec.toBuffer(heartbeatBuff));
|
|
325
|
+
});
|
|
334
326
|
this.heartbeatMisses++;
|
|
335
327
|
}
|
|
336
328
|
resetBufferedMessages() {
|
|
@@ -715,10 +707,8 @@ var ClientTransport = class extends Transport {
|
|
|
715
707
|
*/
|
|
716
708
|
inflightConnectionPromises;
|
|
717
709
|
tryReconnecting = true;
|
|
718
|
-
|
|
719
|
-
constructor(clientId, connectedTo, providedOptions) {
|
|
710
|
+
constructor(clientId, providedOptions) {
|
|
720
711
|
super(clientId, providedOptions);
|
|
721
|
-
this.connectedTo = connectedTo;
|
|
722
712
|
this.inflightConnectionPromises = /* @__PURE__ */ new Map();
|
|
723
713
|
}
|
|
724
714
|
handleConnection(conn, to) {
|
|
@@ -797,12 +787,14 @@ var ClientTransport = class extends Transport {
|
|
|
797
787
|
}
|
|
798
788
|
let reconnectPromise = this.inflightConnectionPromises.get(to);
|
|
799
789
|
if (!reconnectPromise) {
|
|
800
|
-
reconnectPromise = this.createNewOutgoingConnection(to)
|
|
790
|
+
reconnectPromise = this.createNewOutgoingConnection(to).then((conn) => {
|
|
791
|
+
this.sendHandshake(to, conn);
|
|
792
|
+
return conn;
|
|
793
|
+
});
|
|
801
794
|
this.inflightConnectionPromises.set(to, reconnectPromise);
|
|
802
795
|
}
|
|
803
796
|
try {
|
|
804
|
-
|
|
805
|
-
this.sendHandshake(to, conn);
|
|
797
|
+
await reconnectPromise;
|
|
806
798
|
} catch (error) {
|
|
807
799
|
const errStr = coerceErrorString(error);
|
|
808
800
|
this.inflightConnectionPromises.delete(to);
|
|
@@ -1,3 +1,3 @@
|
|
|
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-
|
|
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-d1452d8f.js';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
|
@@ -1,3 +1,3 @@
|
|
|
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-
|
|
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-d1452d8f.js';
|
|
2
2
|
import '../types-3e5768ec.js';
|
|
3
3
|
import '@sinclair/typebox';
|
package/dist/transport/index.js
CHANGED
|
@@ -136,11 +136,11 @@ var Session = class {
|
|
|
136
136
|
*/
|
|
137
137
|
debugId;
|
|
138
138
|
/**
|
|
139
|
-
* Number of messages we've sent along this session (excluding handshake)
|
|
139
|
+
* Number of messages we've sent along this session (excluding handshake and acks)
|
|
140
140
|
*/
|
|
141
141
|
seq = 0;
|
|
142
142
|
/**
|
|
143
|
-
* Number of unique messages we've received this session (excluding handshake)
|
|
143
|
+
* Number of unique messages we've received this session (excluding handshake and acks)
|
|
144
144
|
*/
|
|
145
145
|
ack = 0;
|
|
146
146
|
/**
|
|
@@ -204,21 +204,13 @@ var Session = class {
|
|
|
204
204
|
}
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
-
|
|
208
|
-
return;
|
|
209
|
-
const heartbeatBuff = {
|
|
210
|
-
id: unsafeId(),
|
|
211
|
-
to: this.to,
|
|
212
|
-
from: this.from,
|
|
213
|
-
seq: this.seq,
|
|
214
|
-
ack: this.ack,
|
|
207
|
+
this.send({
|
|
215
208
|
streamId: "heartbeat",
|
|
216
209
|
controlFlags: 1 /* AckBit */,
|
|
217
210
|
payload: {
|
|
218
211
|
type: "ACK"
|
|
219
212
|
}
|
|
220
|
-
};
|
|
221
|
-
this.connection.send(this.codec.toBuffer(heartbeatBuff));
|
|
213
|
+
});
|
|
222
214
|
this.heartbeatMisses++;
|
|
223
215
|
}
|
|
224
216
|
resetBufferedMessages() {
|
|
@@ -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-d1452d8f.js';
|
|
5
|
+
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-0547e840.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-d1452d8f.js';
|
|
5
|
+
import { P as PayloadType, R as RiverError, a as Procedure, S as ServiceContext, b as Result, c as RiverUncaughtSchema } from '../builder-0547e840.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-TVRCTAL2.js";
|
|
5
5
|
import "../chunk-5IZ2UHWV.js";
|
|
6
6
|
import {
|
|
7
7
|
Session,
|
|
8
8
|
defaultSessionOptions
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-NJ25LQPI.js";
|
|
10
10
|
import {
|
|
11
11
|
coerceErrorString
|
|
12
12
|
} from "../chunk-GFRAOY75.js";
|
package/package.json
CHANGED